STMicroelectronics STM32 CPU Support Package

This package contains project templates and system files for the STMicroelectronics STM32.

CrossWorks Version 3 Installation Instructions

To install this support package
  1. Click the Tools > Package Manager menu option to open the package manager window.
  2. Right click on the STMicroelectronics STM32 CPU Support Package entry and select Install Selected Packages.
  3. Click Next to take you to the summary page.
  4. Click Next to install the package.
  5. Click Finish to close the package manager window.
  6. Click the Tools > Show Installed Packages.
  7. Click on the STMicroelectronics STM32 CPU Support Package link to view the package and its contents.
To manually install this support package
  1. If you have not done so already, follow the CMSIS 4 CMSIS-CORE Support Package and CrossWorks Tasking Library Package installation instructions.
  2. Download the file STM32_V3.hzq using your web browser.
  3. Click the Tools > Manually Install Packages menu option.
  4. Select the file you have just downloaded to install the package.
  5. Click the Tools > Show Installed Packages.
  6. Click on the STMicroelectronics STM32 CPU Support Package link to view the package and its contents.

Release Notes

3.17

3.16

3.15

3.14

3.13

3.12

3.11

3.10

3.9

3.8

3.7

3.6

3.5

3.4

3.3

3.2

3.1

3.0

Documentation

Creating STM32 Projects

To create a new STM32 project
To build and debug an application the runs in Flash memory
To make the application startup from reset

STM32 Project Specifics

Target Processor

Once a project has been created you can select different target processors by right clicking on the project node in the project explorer and selecting the Target Processor entry.

Selecting the target processor will specify the memory map that is used for the build and debug. You can view the selected memory map by right clicking on the project node in the project explorer and selecting View Memory Map or View Memory Map (as text).

Selecting the target processor will cause the appropriate preprocessor definition to be defined for use with the ST CMSIS header file.

For devices that have an FPU the preprocessor definition __FPU_PRESENT is defined.

Section Placement

CrossStudio for ARM supports STM32 projects running applications in a number of different memory configurations. You can select the memory configuration you require by right clicking on the project node in the project explorer and selecting the Placement entry.

For STM32 projects the set of placements are:

Stack and Heap Sizes

The stack and heap sizes are set to be 128 bytes by default when a project is created. This enables projects to run on the smallest of the STM32 processors. It is likely that you will need to change these values when developing applications to run on the larger of the STM32 processors.

Target Startup Code

The startup code STM32_Startup.s is common to all STM32F and STM32L processors. There are a set of preprocessor defines that configure the startup code and are documented in the startup file itself. The startup code calls out to a weak symbol SystemInit with the stack pointer set to the top of RAM. The SystemInit function can be used to set the CPU clock or configure any external memories prior to the C initialisation code as such it cannot access initialised static data.

The startup code declares symoblic names (and weak implementations) for each interrupt service routine, for example the EXTI0_IRQHandler function will be called when this interrupt occurs. If you are porting code that has application specific interrupt service routine names then you can use the preprocessor definitions to rename the symbol for example EXTI0_IRQHandler=MyEXTI0ISR.

Target Script

The target script STM32_Target.js is used by the debugger to reset the target board.

The target script will program the DBGMCU register so that the STM32 watchdog timers are stopped when in debug mode and the STM32 lower-power mode debugging is enabled.

The target script provides some support for programming the USER option byte of the STM32F10x, STM32L and STM32F2xx/STM32F4xx. To use these you should:

For STM32F10x targets:

For STM32L targets:

For STM32F2xx/STM32F4xx targets:

You should then disconnect the target interface and power cycle the board.

STM32L EEPROM Support

The STM32L memory map files and flash loader supports loading the EEPROM which can be used as follows:

      extern unsigned eevar  __attribute__ ((section(".eeprom")));
      unsigned eevar = 12;
      
CCM/TCM Support

You should select the Flash TCM placement. To place code for ITCM in the section .text_tcm you can use the following:

      void onTimer(void)__attribute__ ((section(".text_tcm")));
      

or you can set the project property Code Section Name to .text_tcm on the compilation units that you wish to be placed in ITCM. To place zeroed data you can use the following:

      extern unsigned zeroed  __attribute__ ((section(".bss_tcm")));
      unsigned zeroed;
      

or you can set the project property Zeroed Section Name to .bss_tcm on the compilation units that you wish to be placed in DTCM. To place initialised data you can use the following:

      extern unsigned initialised  __attribute__ ((section(".data_tcm")));
      unsigned initialised=12;
      

or you can set the project property Data Section Name to .data_tcm on the compilation units that you wish to be placed in DTCM.

When using the STM32F3 devices with CCM you can use the Section Placement Macros project property as follows ITCM_NAME=CCM_RAM;DTCM_NAME=CCM_RAM to enable usage of the above TCM support.

STM32F7 ITCM Flash Support

When using the STM32F7 devices you can use the Section Placement Macros project property as follows FLASH_NAME=ITCM_FLASH to locate the code in ITCM flash memory.

Memory Simulator

An STM32 memory simulator is provided that simulates the memories of the various STM32 devices. The memory simulation parameter (which is set by the Target Processor selection) specifies the device name, the size of the internal Flash and RAM memories and then optionally the sizes of 4 FSMC Flash/RAM memories.

CMSIS support

CMSIS header files and source are included as part of the new project setup.

Known problems

The "Connect With Reset" project property doesn't work with the original ST-LINK and also causes the part name detection to fail on Cortex-M0 devices.