Im using STM32F429I-DISC1 and Keil uVision v5
Ive written a simple example to demonstrate task priority setting using handles however the code only functions if I first delcare an unused TaskHandle_t (By functioning I mean the red LED blinks whilst the green LED stays static). When the unused TaskHandle_t is removed both LEDs blink (ie task priority is the same for both tasks)
/*
Simple blinky program converted to FreeRTOS
GnLed: PG13
RdLed: PG14
*/
#include "stm32f4xx_hal.h" // Keil::Device:STM32Cube HAL:Common
#include "FreeRTOS.h" // ARM.FreeRTOS::RTOS:Core
#include "task.h" // ARM.FreeRTOS::RTOS:Core
#define gn_led GPIO_PIN_13
#define rd_led GPIO_PIN_14
void GPIO_Init(void);
void vGnLedControllerTask(void* pvParam);
void vRdLedControllerTask(void* pvParam);
TaskHandle_t test; //When this line is added code functions as expected
TaskHandle_t rd_Handle, gn_Handle;
int main()
{
GPIO_Init();
xTaskCreate(vGnLedControllerTask,
"Green Led Controller",
100,
NULL,
1,
&gn_Handle
);
xTaskCreate(vRdLedControllerTask,
"Red Led Controller",
100,
NULL,
1,
&rd_Handle
);
vTaskStartScheduler();
while(1){};
}
void vGnLedControllerTask(void* pvParam)
{
while(1)
{
HAL_GPIO_TogglePin(GPIOG, gn_led);
for(int i=0; i<1000000; i++){}
vTaskPrioritySet(rd_Handle, 2);
}
}
void vRdLedControllerTask(void* pvParam)
{
while(1)
{
HAL_GPIO_TogglePin(GPIOG, rd_led);
for(int i=0; i<1000000; i++){}
}
}
void GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
__HAL_RCC_GPIOG_CLK_ENABLE();
HAL_GPIO_WritePin(GPIOG, GPIO_PIN_13|GPIO_PIN_14, GPIO_PIN_RESET);
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
}