AnsweredAssumed Answered

freeRTOS task not working

Question asked by ghanmy.montassar on Jul 7, 2015
Latest reply on Jul 17, 2015 by ghanmy.montassar
Hello there, I wrote this simple code to test freeRTOS on my stm32f4 discovery , 
the code compiles nicely and give no errors but BlinkLedTask does not Blink the led on the board.


#include <stm32f4xx.h>
#include <misc.h>                
#include <stm32f4xx_rcc.h>
#include <stm32f4xx_usart.h> 
#include <stm32f4xx_gpio.h>
#include "FreeRTOS.h"
#include "task.h"
#include <math.h>
#include <misc.h>


#define LED_GREEN      12
#define LED_ORANGE     13
#define LED_RED        14
#define LED_BLUE       15




void init_LED();


void BlinkLedTask(void);


int main(void) {
  uint8_t ret;


  SystemInit();
  //NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);


  init_LED();
  // Create a task
  ret = xTaskCreate("BlinkLedTask", "FPU", configMINIMAL_STACK_SIZE, NULL, NULL, NULL);


  if (ret == pdTRUE) {
       GPIOD->BSRRL = (1 << 12);
    vTaskStartScheduler();  // should never return
  } else {
       GPIOD->BSRRL = (1 << 14);
    // --TODO blink some LEDs to indicate fatal system error
  }


  for (;;);
}


void vApplicationTickHook(void) {
}


void vApplicationMallocFailedHook(void) {
  taskDISABLE_INTERRUPTS();
  for(;;);
}


void vApplicationIdleHook(void) {
}


void vApplicationStackOverflowHook(xTaskHandle pxTask, signed char *pcTaskName) {
  (void) pcTaskName;
  (void) pxTask;
  taskDISABLE_INTERRUPTS();
  for(;;);
}
void BlinkLedTask(void)
   {
       for( ;; )
       {
            GPIOD->BSRRL = (1 << 13);
       }


       vTaskDelete( NULL );
   }


void init_LED()
{
     int pin = LED_GREEN;
     //
     // Initialise the Clock.
     RCC->AHB1ENR |= RCC_AHB1Periph_GPIOD;
     //
     //
     GPIO_InitTypeDef GPIO_InitStructure;


     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
     GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
     GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
     GPIO_Init(GPIOD, &GPIO_InitStructure);
     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
     GPIO_Init(GPIOD, &GPIO_InitStructure);
}

Outcomes