Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

freeRTOS Task Not Working

Status
Not open for further replies.

Montassar Ghanmy

Junior Member level 2
Joined
Feb 17, 2015
Messages
21
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
159
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.

Code:
#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);
}

Please let me know if I'm doing anything wrong ??
PS : The green LED, as written in the code, blinks to show that freeRTOS runs with no problem.
 

Everything related to FreeRTOS in your post looks ok. Have you tested all the LEDs outside of a FreeRTOS app to ensure you have the start up code, linker script, etc. correct? For example, have you tested the LEDs from main() before you call vTaskStartScheduler()?

I don't think its related to your existing problem, because you are not running interrupts, but you will need the call to NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);, which you currently have commented out.

You don't say which STM32 part or which compiler you are using, but perhaps there is something here you could use as a base? https://www.freertos.org/a00090.html#ST If not then the Atollic tools come with examples for most STM32 parts and boards, albeit rather basic example they will at least get you started.

I don't understand your comment about BlinkLedTask not blinking on the board, but that the green LED does blink...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top