Hello. I am new to FreeRTOS.
I have analyzed and understood the Scheduling method using Task.
I want to run the PID control source through FreeRTOS scheduling.
I included several functions in the FreeRTOS, such as the libraries tm
stm32f4delay.h and tm
stm32f4delay.c, which were imported from outside, and found that SysTick
Handler duplicated.
tmstm32f4_delay.c defines the millis and delay functions we need to do the PID.
To solve this problem, I commented out the SysTick
Handler in the section of tmstm32f4
delay.c and solved the compilation problem. I understood that [[#define xPortSysTickHandler SysTickHandler]], which is embedded in FreeRTOS, is used for interrupts and is absolutely necessary.
After all, we need to implement the Delay function needed for the PID. The tool I am using is IAR.
The above is a description of the situation I experienced, and the questions are as follows.
- I want to use the function defined in the header file included in TaskFunction via vTaskDelay. Can this header file serve as a delay through a function called vTaskDelay?
- I read the contents of https://www.freertos.org/FreeRTOSSupportForumArchive/November2013/freertosconfigTICKRATEHZ8fc54ac4j.html, but I do not understand.
We implemented a delay using the vTaskDelay function, but this did not allow accurate ms Delay.
I set it to #define configTICKRATEHZ ((TickTypet) 1000) and I wanted a delay of 500ms, but when I measured it with an oscilloscope, it took about 2 seconds of delay.
There is only one externalLED_TASK task to operate.
//delay.h function
void external
delaytest (void)
{
// const TickType
t xDelay = 500 / portTICKPERIOD
MS;
unsigned int niCnt = 0;
for (;;)
{
// vTaskList (ptrTaskList);
// printf (“ptrTaskList n”);
if ((n
iCnt% 2) == 0)
{
GPIOSetBits (GPIOD, GPIO
Pin4);
}
else if ((n
iCnt% 2) == 1)
{
GPIOResetBits (GPIOD, GPIO
Pin4);
}
// puts (“LED2”);
printf (“PD4 ::::% d n”, n_iCnt);
vTaskDelay (500);
n_iCnt ++;
}
}
//main.c Taskfunction
void external
LEDTASK (void * pvParameter)
{
external
delaytest ();
/ *
for (;;)
{
external
delaytest ();
}
* /
}
- Is the structure I think is wrong? If so, can you use vTaskDelay to delay for exactly one second? Or can I re-implement Delay?
I need help.