| Package Title | STM32 CPU Support Package |
| Package Version | 2.5 |
| CPU | STMicroelectronics STM32 |
| Required Additional Packages | None |
| Required CrossStudio Version | 2.0.3 or later |
This package contains project templates and system files for the STM32.
Package Installation Instructions
CrossWorks Version 2.x Installation Instructions
To install this support package using CrossStudio:
- Click the Tools > Package Manager menu option to open the package manager window.
- Right click on the STM32 CPU Support Package entry and select Install Selected Packages.
- Click Next to take you to the summary page.
- Click Next to install the package.
- Click Finish to close the package manager window.
Alternatively, to manually install this support package:
- Download the file STM32.hzq using your web browser.
- Click the Tools > Manually Install Packages menu option.
- Select the file you have just downloaded to install the package.
Supported Targets
STM32F100 Series
STM32F100C4, STM32F100C6, STM32F100C8, STM32F100CB, STM32F100R4, STM32F100R6, STM32F100R8, STM32F100RB, STM32F100V8, STM32F100VB.
STM32F101 Series
STM32F101C4, STM32F101C6, STM32F101C8, STM32F101CB, STM32F101R4, STM32F101R6, STM32F101R8, STM32F101RB, STM32F101RC, STM32F101RD, STM32F101RE, STM32F101RF, STM32F101RG, STM32F101T4, STM32F101T6, STM32F101T8, STM32F101V8, STM32F101VB, STM32F101VC, STM32F101VD, STM32F101VE, STM32F101VF, STM32F101VG, STM32F101ZC, STM32F101ZD, STM32F101ZE, STM32F101VF, STM32F101VG.
STM32F102 Series
STM32F102C4, STM32F102C6, STM32F102C8, STM32F102CB, STM32F102R4, STM32F102R6, STM32F102R8, STM32F102RB.
STM32F103 Series
STM32F103C4, STM32F103C6, STM32F103C8, STM32F103CB, STM32F103R4, STM32F103R6, STM32F103R8, STM32F103RB, STM32F103RC, STM32F103RD, STM32F103RE, STM32F103RF, STM32F103RG, STM32F103T4, STM32F103T6, STM32F103T8, STM32F103TB, STM32F103V8, STM32F103VB, STM32F103VC, STM32F103VD, STM32F103VE, STM32F103VF, STM32F103VG, STM32F103ZC, STM32F103ZD, STM32F103ZE, STM32F103ZF, STM32F103ZG.
STM32F105 Series
STM32F105R8, STM32F105RB, STM32F105RC, STM32F105V8, STM32F105VB, STM32F105VC.
STM32F107 Series
STM32F107RB, STM32F107RC, STM32F107VB, STM32F107VC.
STM32L15x Series
STM32L151C8, STM32L151CB, STM32L151R8, STM32L151RB, STM32L151V8, STM32L151VB, STM32L152C8, STM32L152CB, STM32L152R8, STM32L152RB, STM32L152V8, STM32L152VB.
Package Version History
2.5
- Fixed address of ETH_DMAIER in memory maps and header files.
- Added STM32L device support.
- Added support for STM32F101xF/G and STM32F103xF/G devices.
- Reset script now turns off watchdogs and enables low power mode debugging.
- Reset script has functions that enable the option bytes to be programmed.
- Sample support for ST STM32L152-EVAL board.
- Memory simulator can simulate 4 FSMC Flash/SRAM memories.
2.4
- Added value line device support.
- Flash loader supports flash breakpoints.
- Added Flash Copy To RAM section placement property group.
- Section placement property group now selects the loader to use and as such there is no requirement for Flash/RAM configurations.
- Added start macros to the first sections of the placement files which enables memory to be reserved at the start of the segment by defining the section placement macros.
- New CTL projects now have the STM3210B_EVAL/stm32_ctl_board.c file included.
- CMSIS Version 1.30 supplied.
- CMSIS stm32f10x.h Version 3.3.0 supplied.
- Sample support for ST STM32100B-EVAL board.
- Sample support for IAR STM32F107VC-SK board.
- Samples now use the CMSIS stm32f10x.h rather than the CrossWorks targets/stm32f10x.h.
2.3
- Added missing TIM1 to connectivity line memory maps and header files.
2.2
- Added support for the STM32F103TB.
- Corrected bxCAN and AFIO_MAPR memory map and header definitions for connectivity line devices.
2.1
- The vector table offset register is now always configured to allow the start address of FLASH configuration programs to be moved away from 0x00000000 without modification of startup code.
2.0
- Initial Release.
1) Creating STM32 Projects
To create a new STM32 project
- Select the File > New > New Project menu item.
- Select the appropriate Generic STM32 from the Categories list.
- Select the required project template type from the Templates list.
- Set the required project name and location directory.
- Click OK.
To build and debug an application the runs in Flash memory
- Select the project to work on by using the Project > Set Active Project menu option.
- Select the configuration you require by using the Build > Set Active Build Configuration menu option.
- Right click on the project node in the project explorer and select the Flash placement.
- Build the project by using the Build > Build Project menu option.
- Connect to the appropriate target in the target window.
- Download and start debugging the current project by using Debug > Start Debugging.
To make the application startup from reset
- Right click on the project node in the project explorer and select Properties...
- In the properties window scroll down to the Preprocessor Options section.
- Type STARTUP_FROM_RESET into the Preprocessor Definitions property editor.
2) 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 preprocessor definition __TARGET_PROCESSOR to be set to the specified processor name when you compile the project.
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:
- Flash application runs in internal Flash memory.
- Flash Copy To RAM application starts in internal flash and copies itself to run internal RAM memory.
- RAM application runs internal RAM memory.
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 Reset Script
The reset script STM32_Target.js is used by the debugger to reset the target board. This script will use the SRST signal so in order to reset the target properly and therefore debug your application reliably from a defined state the SRST signal should be connected.
The reset 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 reset script provides some support for programming the option bytes of the STM32F10x and STM32L. To use these you should:
- Connect to the appropriate target.
- Use View | Script Console to display the script console.
- In the script console type load("targets/STM32/STM32_Target.js") which should return true on success.
For STM32F10x targets:
- STM32F_EraseOptionBytes() which will erase all of the option bytes - this function must be called first.
- STM32F_Unprotect() to disable read protection - this function should be called unless you want to enable read protection.
- STM32F_SetUSER(b) and pass the desired USER byte value as the argument.
- STM32F_SetData0(b) and pass the desired user Data0 byte value as the argument.
- STM32F_SetData1(b) and pass the desired user Data1 byte value as the argument.
For STM32L targets:
- STM32L_SetUSER(b) and pass the desired USER byte value as the argument.
You should then disconnect the target interface and power cycle the board.
STM32 Internal Flash Loader
The source code to the flash loaders (click to load solution) for the internal Flash of the STM32F10x and STM32L is provided.
Memory Simulator
An STM32 memory simulator is provided that simulates the memories of the various STM32F10x and STM32L 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.
Header Files
Header files are generated from the memory map files and can be included using the file targets/STM32F10x.h. These files are provided for backward compatibility, the CMSIS header files are the preferred solution.
CMSIS support
CMSIS header files and library are included as part of the new project setup.
- core_cm3.h general Cortex-M3 CMSIS header file.
- stm32f10x.h STM32F10x specific header file.
- stm32l1xx.h STM32L specific header file.
CTL support
The file STM32_ctl.c implements the CTL system timer using the Cortex-M3 SysTick timer. The timer is configured to interrupt at a 10 millisecond rate and increment the CTL system timer by 10 to give a millisecond timer. The implementation uses the CMSIS SystemFrequency global variable to determine the CPU clock frequency. The CTL samples that are provided in this package have board specific files that implement this variable.
The CTL interrupt support functions ctl_global_interrupts_set, ctl_set_priority, ctl_unmask_isr and ctl_mask_isr are implemented in this file. The implementation uses the lowest half of the available NVIC priorities (top bit set in the priority) for CTL interrupts and disables global interrupts by raising the NVIC basepriority above the highest CTL priority. This enables you to use the upper half of the NVIC priorities for interrupts that do not use CTL and should not be disabled by a CTL interrupt.
3) CrossWorks Shared Sample Projects
The following project files are supplied that can be used to run the standard CrossWorks shared samples.
- IAR_STM32F103ZE_SK Shared Samples (click to load project)
- IAR_STM32F107VC_SK Shared Samples (click to load project)
- Keil_MCBSTM32 Shared Samples (click to load project)
- Keil_MCBSTM32E Shared Samples (click to load project)
- ST_STM3210B_EVAL Shared Samples (click to load project)
- ST_STM3210C_EVAL Shared Samples (click to load project)
- ST_STM3210E_EVAL Shared Samples (click to load project)
- ST_STM32100B_EVAL Shared Samples (click to load project)
- ST_STM32L152_EVAL Shared Samples (click to load project)
- ST_STM3210E_EVAL External Flash Loader Solution (click to load project)
4) CTL Sample Projects
The following project files are supplied that can be used to run the standard CrossWorks CTL samples.
- IAR_STM32F103ZE_SK CTL Samples (click to load project)
- IAR_STM32F107VC_SK CTL Samples (click to load project)
- Keil_MCBSTM32E CTL Samples (click to load project)
- Keil_MCBSTM32E CTL Samples (click to load project)
- ST_STM3210B_EVAL CTL Samples (click to load project)
- ST_STM3210C_EVAL CTL Sample (click to load project)
- ST_STM3210E_EVAL CTL Samples (click to load project)
- ST_STM32100B_EVAL CTL Samples (click to load project)
- ST_STM32L152_EVAL CTL Samples (click to load project)