-
Notifications
You must be signed in to change notification settings - Fork 0
STM32CubeIDE
As with any other IDE, the STM32CubeIDE faciciltates the developement of Programs. It features tools for debugging, a menu in which you can import example projects, an ioc-file for code generation and many other things. We will present you some features that you need to work on your own project.
Once you launch the STM32CubeIDE you can import new projects. First locate the column on the lefthand above which "Project Explorer" is written. Rightclick on any free space and choose import. The most used options for us were "General > Exisitng Projects into Workspace" or "General > Import STM32Cube Example"
- If you import an existing project navigate to the folder which includes the .project file. If there are nested projects choose the folder with the top-level .project-file.
- If you import an example choose the board you are using (in our case the NUCLEO-L552ZE-Q). Please note that there is a rider named "Example" which contain something you can reuse. We used FreeRTOS_SecureIOToggle_TustZone, which might be easier to start with if you want to continue with our project. Afterwards you can choose whether TrustZone should be enabled and if you would like to configure the PINs with there default configuration.
To build your project, choose the project click on the arrow next to the hammer, choose your build configuration and then click the hammer. Once the project is build, you may run or debug the project, according to the build configuration. If you run a project which contains other projects (such as the FreeRTOS_SecureIOToggle_TrustZone), you must consider the dependencies. If you import examples there is a readme specifiying the details on how to build and launch. Otherwise the following isntructions should build and flash every project correctly:
- Select the Project containing the Secure.elf
- At the top of the CubeIDE, click the arrow next to the Debug- or Run-Icon > Configurations, click on the Startup Rider > add xxxx/NonSecure.elf
- Click Apply, close the window
- Build the secure project
- Build the NonSecure project
- Select the Secure-Project and hit Debug/Run
The STM32CubeIDE offers automatic code generation, which can be used by configuring the .ioc-File. What needs to be considered when generating code depends - of course - on the application that is developed, so we can't tell you what you exactly have to do, but we will explain you how we configured the .ioc-file to use FreeRTOS on the one hand and to enable interrupts on the other hand. After changes have been made to the .ioc-file save it and the code generation should take place.
Once you open the .ioc-File in the, navigate to the point Middleware on the left hand side of the provided GUI. There you choose FreeRTOS and choose the interface you want to use. Once you have chosen a CMSIS version you have the option to configure other parameters. Mainly interessting for our application is the configuration of the "Tasks and Queues" rider. Here you can add new tasks and configure already exisitng tasks. One think you should be cautious about is for example to make sure that you allocate enough Stack for the tasks. (see known issue when calling osDealy). Note: When you use FreeRTOS, you may also need to change the timer used in the .ioc-file
Before you can enable Interrupts you have to configure the coresponding pin to generate Interrupts. To do so, choose the pin in the picture on the right hand side and in the dropdown menu choose GPIO_EXTIXX. In our case we wanted the user Button to generate interrupts. We searched in the documentation for the coressponding pin (PC13) and choose in the menu GPIO_EXTI13. Now, open the System Core dropdown menu on the lefthand side of the GUI and choose, there select GPIO, search for the pin you have configured beforehand, select it and assign the pin a context (secure or nonsecure). We didn't need to change anything about the GPIO mode, but you might do so. In a last step choose the rider NVIC in the GPIO-view and enable Interrupts. Once you auto-generate code there should be a designated code segment in the stm32l5xx_it.c file in which you may write your interrupt handling.
If you need to add files manually to the project, you should use already use directories in which already source-code exists. That way you avoid the must problems arisng with the IDE not findnig your file. If, on the other hand, you want to use an external library that you want to add manually, you need to add the paths to the to the project. You do so by right clicking on the blue project file in the IDE > Properties > C/C++ General > Paths and Symbols, there you can add header files that are neede. Note: For sourcecode, you still need to add links or files as described above