muratursavas wrote on Thursday, January 26, 2012:
Hi,
I’m a newbie about FreeRTOS and checked the forum for my problem but couldn’t find anything.
My purpose is simply making FreeRTOS run two tasks concurrently with different frequencies. I’m using vTaskDelay to create frequency difference. From my readings, tasks should wait with (given value) * (tick period). In the mean time, while in the DELAYED state, the other task should run (both tasks have the same priority).
Here is my code:
main.c
#include <stdio.h>
#include "stm32f10x.h"
#include "FreeRTOS.h"
#include "task.h"
xTaskHandle TaskHandle1;
xTaskHandle TaskHandle2;
void TaskFunction1(void *);
void TaskFunction2(void *);
int main(void)
{
SystemInit();
printf("Hello World!\n");
xTaskCreate(TaskFunction1, // pointer to function
"Task1", // Task name string for debug purposes
100, // Stack depth as word
NULL, // function parameter (like a generic object)
1, // Task Priority (Greater value has higher priority)
&TaskHandle1); // Task handle
xTaskCreate(TaskFunction2, // pointer to function
"Task2", // Task name string for debug purposes
100, // Stack depth as word
NULL, // function parameter (like a generic object)
1, // Task Priority (Greater value has higher priority)
&TaskHandle2); // Task handle
printf("Task Handles: Task1=%u, Task2=%u\n", TaskHandle1, TaskHandle2);
vTaskStartScheduler();
for(;;);
}
void TaskFunction1(void *pvParameters)
{
for(;;)
{
vTaskDelay(10);
printf("Task 1\n");
}
}
void TaskFunction2(void *pvParameters)
{
for(;;)
{
vTaskDelay(30);
printf("Task 2\n");
}
}
FreeRTOSConfig.h
#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ( ( unsigned long ) 72000000 )
#define configTICK_RATE_HZ ( ( portTickType ) 10000 )
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 )
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 128 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 17 * 1024 ) )
#define configMAX_TASK_NAME_LEN ( 16 )
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskCleanUpResources 0
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
/* This is the raw value as per the Cortex-M3 NVIC. Values can be 255
(lowest) to 0 (1?) (highest). */
#define configKERNEL_INTERRUPT_PRIORITY 255
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xb0, or priority 11. */
/* This is the value being used as per the ST library which permits 16
priority values, 0 to 15. This must correspond to the
configKERNEL_INTERRUPT_PRIORITY setting. Here 15 corresponds to the lowest
NVIC value of 255. */
#define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15
I’m using IAR 6.3 and debugging with it’s simulator. Everything compiles fine. But I just receive some errors from debugger:
Here is the debugger log:
Thu Jan 26, 2012 09:39:57: Download complete.
Thu Jan 26, 2012 09:39:57: Loaded debugee: D:\RASATRON\Projects\Experiments\IAR FreeRTOS Trial 1\Debug\Exe\IAR_FreeRTOS_T1.out
Thu Jan 26, 2012 09:39:57: Target reset
Thu Jan 26, 2012 09:39:57: non-empty line in wrong state
Thu Jan 26, 2012 09:39:57: There was 1 errors during the initialization of the debugging session.
Thu Jan 26, 2012 09:39:57: Error (col 15): No such field.
Thu Jan 26, 2012 09:39:57: Error (col 15): No such field.
Thu Jan 26, 2012 09:39:57: Error (col 15): No such field.
Thu Jan 26, 2012 09:39:57: Error (col 1): Unknown or ambiguous symbol. uxTaskNumber