cancel
Showing results for 
Search instead for 
Did you mean: 

Creating STM32CubMX ioc project for older STM32Cube firmware examples from the STM32Cube firmware repository part 2

AME MCU SM
ST Employee

In continuation of part 1 of this article [1], we will also briefly discuss how you can easily export your STM32 project to different STM32 series using the “List pinout compatible MCUs” option in the STM32CubeMX.

1 Troubleshooting sourcing the STM32F4

1.1 Methods used for easily importing your old STM32 project to a new STM32 series: 

If you are having problems with sourcing your STM32 series component, you can easily export your MCU project ioc file to a different STM32 series using two different methods. For this feature demonstration, we pick the Nucleo-L476 but you can use other MCU of your choice as well.
Two options for importing your project:

1) Method 1:
How to switch from one STM32 to another using STM32CubeMX

2) Method 2:
MCU1 to MCU2 migration option within STM32CubeIDE

 

1339.png

 

1.2 Process for importing your project:

This time, we open the STM32F4 ioc project that we have already created in the previous section. We use method 2 (“List pinout compatible MCUs” feature), discussed in the above link, for importing our project to a new MCU.
 

Figure 18: ioc configuration: Exporting pinout and alternative functions to a new STM32 series of choice. Using “List pinout compatible MCUs (Alt-L)”.Figure 18: ioc configuration: Exporting pinout and alternative functions to a new STM32 series of choice. Using “List pinout compatible MCUs (Alt-L)”.


 

Select the desired MCU that you would like to transfer your pinout to using the “Alt-L” keyboard shortcut.

 

Figure 19: ioc configuration: list of pin compatible STM32L4 MCUs.Figure 19: ioc configuration: list of pin compatible STM32L4 MCUs.


 

Figure 20: ioc configuration: warning message, indicating the MCU you picked might not be 100% pin compatible with the MCU you are migrating from.Figure 20: ioc configuration: warning message, indicating the MCU you picked might not be 100% pin compatible with the MCU you are migrating from.


 

Note: Sometimes, the pins and functionality do not always transfer to new MCU platform due to pinout or peripheral incompatibilities. In that scenario, STM32CubeMX transfers as much as possible, but you need to manually adjust some of the configurations yourself. 
Figure 21 shows an incorrect pin assignment for the GPIO connected to a pushbutton and other issues that are not observable from the figure like for example: incorrect configuration for the DAC peripheral.

Figure 21: ioc configuration: initial pin settings after we migrate our project to new MCU. Not all settings transferred correctly.Figure 21: ioc configuration: initial pin settings after we migrate our project to new MCU. Not all settings transferred correctly.


 

Using the schematic, we find the correct GPIO connected to the pushbutton on the Nucleo-L476 (“B1 user”): Schematic [2]. For example, the B1 user (Blue) is connected to PC13 on the Nucleo-L476.

 

Figure 22: ioc configuration: pin setting after reconfiguration of DAC peripheral + remapped GPIO EXTI to a new pin (PC13).Figure 22: ioc configuration: pin setting after reconfiguration of DAC peripheral + remapped GPIO EXTI to a new pin (PC13).


 

Figure 23 to 26 show the changes in DAC, DMA, and clock tree settings required for STM32L4.
 

Figure 23: ioc configuration: DAC configuration for the STM32L4.Figure 23: ioc configuration: DAC configuration for the STM32L4.


 

Figure 24: ioc configuration: Interrupt configuration of DAC DMA.Figure 24: ioc configuration: Interrupt configuration of DAC DMA.


 

Figure 25: ioc configuration: setup DMA for memory to DAC peripheral transfers.Figure 25: ioc configuration: setup DMA for memory to DAC peripheral transfers.


 

Figure 26: ioc configuration: setup clock tree (different from our STM32F4 clock tree configuration due to MCU architectural differences).Figure 26: ioc configuration: setup clock tree (different from our STM32F4 clock tree configuration due to MCU architectural differences).

 

1.3 Result:

After compiling the STM32L476 project and running the program, we will observe the following figures as depicted in figures 27 and 28. Figures 27 and 28 replicate the original example project (figs. 1 and 2 respectively) without the STM32CubeMX ioc file.
 

Figure 27: Output based on the new project with the STM32CubeMX ioc configuration file: Triangle wave generated by STM32L476 DAC on PA4.Figure 27: Output based on the new project with the STM32CubeMX ioc configuration file: Triangle wave generated by STM32L476 DAC on PA4.


 

Figure 28: Output based on the new project with the STM32CubeMX ioc configuration file: Custom wave (escalator waveform) generated by the STM32L476 DAC on PA4.Figure 28: Output based on the new project with the STM32CubeMX ioc configuration file: Custom wave (escalator waveform) generated by the STM32L476 DAC on PA4.


 

If you have any issues with the project implementation, please refer to the following link [3] for the completed STM32F4DISCOVERY and STM32L4 Nucleo projects. 
 

Version history
Last update:
‎2023-12-07 05:42 AM
Updated by: