Basic HelloWorld Blink LED using SWSTM32 and bluepill STM32
I am trying to flash an LED using an STM32F103CT8.
I selected FreeRTOS and ONE GPIO (PC13) for the LED.
I have selected TOTAL_HEAP_SIZE 9000 bytes
Inside the “Default Task” I have this:
for (;;)
{
HAL_GPIO_WritePin(USER_LED_GPIO_Port, USER_LED_Pin, 0);
osDelay(1000);
HAL_GPIO_WritePin(USER_LED_GPIO_Port, USER_LED_Pin, 1);
osDelay(1000);
}
But at start of debugging, this code: (everything generated by SWSTM32 and SWD STLINK debugging)
__’‘/* Create the thread(s) */
/* definition and creation of defaultTask */
osThreadDef(defaultTask, StartDefaultTask, osPriorityIdle, 0, 1024);
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
/* USER CODE BEGIN RTOS_THREADS */
/* USER CODE END RTOS_THREADS */
/* USER CODE BEGIN RTOS_QUEUES */
/* USER CODE END RTOS_QUEUES */
/* Start scheduler */
osKernelStart();’‘__
This code ALWAYS crashes between “defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);”
AND “osKernelStart();”
So even BEFORE the task is created, the system “crashes”.
This is a basic as can be setup.
I have turned “optimization” to “None” in an effort to have the compiler not optimize the task out.
EDIT:
It is a SWSTM32 code generation BUG.
Even though I thought, “FreeRTOS” that SWSTM32 will generate xTaskcreate etc, it uses CMSIS. And this CMSIS code gets passed NULL fucking pointers, that is why the code never runs.
Yay!
Thanks for the help guys!