2015-07-07 09:51 AM
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);
}
2015-07-07 11:12 AM
Please edit your post, and use the Format Code Block tool (Paintbrush [<>]), as it's currently unreadable.
2015-07-11 12:59 PM
Hi there, thank you for replying, please check now and let me know. Thank you !!
2015-07-11 07:10 PM
2015-07-12 03:53 AM
Still not working :\ ??
I'm suspecting the problem is hereret = xTaskCreate(''BlinkLedTask'', ''FPU'', configMINIMAL_STACK_SIZE, NULL, NULL, NULL);2015-07-12 10:54 AM
Do you have a scope on the LED, because it's probably not going to blink at a visible rate without some delay in the loop.
Not much of a freeRTOS expert, do you have a breakpoint in the loop? How is this ''not working'' being determined? Does xCreateTask() return a failure code? What does it suggest is the problem?2015-07-17 11:18 AM
Indeed that was the problem. Thumbs up !