Loading...
 

SW4STM32 and SW4Linux fully supports the STM32MP1 asymmetric multicore Cortex/A7+M4 MPUs

   With System Workbench for Linux, Embedded Linux on the STM32MP1 family of MPUs from ST was never as simple to build and maintain, even for newcomers in the Linux world. And, if you install System Workbench for Linux in System Workbench for STM32 you can seamlessly develop and debug asymmetric applications running partly on Linux, partly on the Cortex-M4.
You can get more information from the ac6-tools website and download (registration required) various documents highlighting:

System Workbench for STM32


SW4STM32 doesn't move to main loop

Hello!

I am very new to STM32 programming but finally got to manage my first LED toggling project according to the UM1718 user manual for CubeMX tutorial 1 .
What I do’t understand is the fact, that when I break the programflow, the programm doesn’t move to the main while loop but stays in the HAL_TIM_Base_Start_IT(&htim3); function. Why is that?

here is the code snippet:

int main(void)
{

/* USER CODE BEGIN 1 */

/* USER CODE END 1 */

/* MCU Configuration----------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();

/* Configure the system clock */
SystemClock_Config();

/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART2_UART_Init();
MX_TIM3_Init();

/* USER CODE BEGIN 2 */
HAL_TIM_Base_Start_IT(&htim3);

don’t know why, but the post cuted some text away. Heres the complete main:

int main(void)
{

/* USER CODE BEGIN 1 */

/* USER CODE END 1 */

/* MCU Configuration----------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();

/* Configure the system clock */
SystemClock_Config();

/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART2_UART_Init();
MX_TIM3_Init();

/* USER CODE BEGIN 2 */
HAL_TIM_Base_Start_IT(&htim3);

/* USER CODE END 2 */
uint32_t i = 0;
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
i++;

/* USER CODE BEGIN 3 */

}
/* USER CODE END 3 */

}


OK found the problem!
It was due to a compiler optimization, that the empty or even used (with a never used again variable) while loop was ommited. Without optimizatin everything works fine!


Another way you can force the inclusion of the infinite while() loop (with optimization on) would be to declare the i variable volatile, like this:

volatile uint32_t i;
while (1)
{
i++;
}

Doing this is also useful when you want to create a software delay and don’t care about accuracy, like this:

volatile uint32_t i;
for (i = 100000; i > 0; i--) ;

As for use of compiler optimization, I normally set the optimization level to “optimize for debug (-Og)” for the debug build of my projects, and use higher level optimization, normally “optimize for size (-Os)” for the release build.