eaoiyrioeaf wrote on Wednesday, February 22, 2017:
I have defined three tasks, below are the code of these tasks:
static void vThread1( void *pvParameters )
{
//vTaskSetApplicationTaskTag( NULL, ( void * ) 1 );
for(;;){
vTaskDelay( 10000 );
LED_1_LAT=0;
while(U1STAbits.TRMT==0);
UART1_sent((uchar*)"Thread1 Running\r\n\r\r\r",18);
}
}
static void vThread2( void *pvParameters )
{
//vTaskSetApplicationTaskTag( NULL, ( void * ) 2 );
for(;;){
vTaskDelay( 10000 );
LED_1_LAT=1;
while(U1STAbits.TRMT==0);
UART1_sent((uchar*)"Thread2 Running\r\n\r\r\r",18);
}
}
static void vIdle( void *pvParameters )
{
//vTaskSetApplicationTaskTag( NULL, ( void * ) 1 );
for(;;){
Nop();Nop();Nop();Nop();Nop();Nop();Nop();Nop();Nop();Nop();Nop();Nop();Nop();Nop();Nop();Nop();
}
}
Then create above three tasks by below code:
xTaskCreate( vThread1, "Thread1", mainCHECK_TAKS_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
xTaskCreate( vThread2, "Thread2", mainCHECK_TAKS_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
xTaskCreate( vIdle, "IdleThread", mainCHECK_TAKS_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
up to now, the program works well, the serial port keep out put “Thread1 Running” &“Thread2 Running” as I have expected.
When I read through the FreeRTOS manual “Mastering the FreeRTOS™Real Time Kernel”, I chapter 3.8, it’s mentioned the FreeRTOS itself will create a Idle task, so I comment out the Idle task create by me, below is the only part I have modified:
//xTaskCreate( vIdle, "IdleThread", mainCHECK_TAKS_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
the program supposed to work well by then, but the truth is after comment out this statement, the board keeps restarting.
Really have no ideal why this happen, appreciate anyone can help me on this.