cancel
Showing results for 
Search instead for 
Did you mean: 

Blink LEDs in FreeRtos not working in STM32F407G-DISC1 board

VTOL_Aviations
Associate II

I'm trying to Blink 2 leds using freertos. The code in generated by CubeMX. When generating it shows like the image attached below. So I go to Sys tab and select timebase source as TIM1. When I flash the code I'm not able to see any output.

When I still generate the code without changing the timebase source(i.e. timebase source as SysTick), I got an error TIM_HandleTypeDef is not defined(at this void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)). So I included #include "stm32f4xx_hal_tim.h" this line. The code got compiled but not able to see any led blinking on my board.

My main function :

int main(void)

{

 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */

 HAL_Init();

 /* Configure the system clock */

 SystemClock_Config();

 MX_GPIO_Init();

 MX_DMA_Init();

 MX_USART2_UART_Init()

 osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128);

 defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);

 /* USER CODE BEGIN RTOS_THREADS */

 /* add threads, ... */

 if( xTaskCreate( TaskLED1_Blink, "BlinkLED1", 200, NULL, 1, &Task_LED1 ) == !pdPASS)

 {

 return 0;

 }

 if( xTaskCreate( TaskLED2_Blink, "BlinkLED2", 200, NULL, 1, &Task_LED2 ) == !pdPASS)

  {

  return 0;

  }

/* 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 */

 }

 /* USER CODE END 3 */

}

My tasks code :

void TaskLED1_Blink(void *pvParameters)

{

while(1)

{

HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_12);

HAL_Delay(500);

vTaskDelay( pdMS_TO_TICKS( 20 ) );

}

}

void TaskLED2_Blink(void *pvParameters)

{

while(1)

{

vTaskDelay( pdMS_TO_TICKS( 20 ) );

HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_13);

HAL_Delay(500);

}

}

Please help me out with this.

0690X0000088umEQAQ.jpg

0 REPLIES 0