2020-10-04 07:39 PM
I am a biginner of STM32CubeIDE.
I made an example which run timer function with STM32cubeIDE.
But the timer callback function is not run, Even though osTimerStart() is called in StartDefaultTask() function. What should I change?
Thank you in advance.
Here is my source code..
int main(void)
{
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_ADC1_Init();
MX_DFSDM1_Init();
MX_ETH_Init();
MX_FMC_Init();
MX_I2C1_Init();
MX_LTDC_Init();
MX_QUADSPI_Init();
MX_SAI1_Init();
MX_SDMMC1_SD_Init();
MX_USART1_UART_Init();
MX_USB_OTG_FS_PCD_Init();
MX_USB_OTG_HS_PCD_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Init scheduler */
osKernelInitialize();
/* creation of myTimer01 */
myTimer01Handle = osTimerNew(Callback01, osTimerPeriodic, NULL, &myTimer01_attributes);
/* creation of myTimer02 */
myTimer02Handle = osTimerNew(Callback02, osTimerPeriodic, NULL, &myTimer02_attributes);
defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);
/* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */
/* USER CODE END RTOS_THREADS */
/* Start scheduler */
osKernelStart();
/* We should never get here as control is now taken by the scheduler */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
} // End of main()
...
..
.
/* USER CODE END Header_StartDefaultTask */
void StartDefaultTask(void *argument)
{
/* USER CODE BEGIN 5 */
osDelay(10);
osTimerStart(myTimer01Handle, 20);
osDelay(10);
osTimerStart(myTimer02Handle, 20);
/* Infinite loop */
for(;;)
{
if(osTimerIsRunning(myTimer01Handle) ) {
printf(" Tmr callback01 is running ....\n\r");
}
else {
printf(" Tmr Callback01 is not working... Re-Start Timer....\n\r");
osTimerStart(DGP_Tx_TMRHandle, 20);
}
osDelay(1000);
if(osTimerIsRunning(myTimer02Handle) ) {
printf(" Tmr is Callback02 running ....\n\r");
}
}
/* USER CODE END 5 */
}
/* Callback01 function */
void Callback01(void *argument)
{
/* USER CODE BEGIN Callback01 */
while(1) {
printf(" Timer Callback 01 is running .....\n\r");
osDelay(100);
}
/* USER CODE END Callback01 */
}
/* Callback02 function */
void Callback02(void *argument)
{
/* USER CODE BEGIN Callback02 */
while(1) {
printf(" Timer Callback 02 is running .....\n\r");
osDelay(100);
}
/* USER CODE END Callback02 */
}