jonginkk wrote on Friday, January 12, 2018:
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_stm32f4_delay.h and tm_stm32f4_delay.c, which were imported from outside, and found that SysTick_Handler duplicated.
tm_stm32f4_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 tm_stm32f4_delay.c and solved the compilation problem. I understood that [[#define xPortSysTickHandler SysTick_Handler]], 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/FreeRTOS_Support_Forum_Archive/November_2013/freertos_configTICK_RATE_HZ_8fc54ac4j.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 configTICK_RATE_HZ ((TickType_t) 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 external_LED_TASK task to operate.
//delay.h function
void external_delay_test (void)
{
// const TickType_t xDelay = 500 / portTICK_PERIOD_MS;
unsigned int n_iCnt = 0;
for (;;)
{
// vTaskList (ptrTaskList);
// printf (“ptrTaskList \ n”);
if ((n_iCnt% 2) == 0)
{
GPIO_SetBits (GPIOD, GPIO_Pin_4);
}
else if ((n_iCnt% 2) == 1)
{
GPIO_ResetBits (GPIOD, GPIO_Pin_4);
}
// puts (“LED2”);
printf (“PD4 ::::% d \ n”, n_iCnt);
vTaskDelay (500);
n_iCnt ++;
}
}
//main.c Taskfunction
void external_LED_TASK (void * pvParameter)
{
external_delay_test ();
}
I have implemented a for (; loop in external_delay_test, which is not implemented as a loop in TaskFunction itself.
We have confirmed that it works well when scheduling multiple TaskFunctions.
- 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.