FreeRTOS 应用集锦

3450阅读 0评论2013-04-15 qiushui_007
分类:C/C++

参数配置   http://www.openmcu.net/post/kernel-config.html
内存管理   http://openmcu.net/post/FreeRTOS_MemoryManagement.html

1. 修改代码后, 系统运行了1个多小时, 异常报告 IDLE任务异常. 

signed char *pcGetCurTaskName(void);
void HardFaultException(unsigned int * hardfault_args,unsigned int *sp)
{
#ifdef HAVE_LCD
#if OS_USE_UCOS
sprintf(str, "Hard fault: task: %s", OSTCBPrioTbl[OSTCBCur->OSTCBPrio]->OSTCBTaskName);
#elif OS_USE_FREERTOS
sprintf(str, "Hard fault: task: %s", pcGetCurTaskName());
#endif
gui_text(0, 224, str, strlen(str), RGB565_RED, 0xffff);
#endif
}

---  FreeRTOS的 IDLE任务相关代码如下, tasks.c中
void vTaskStartScheduler( void )
{
portBASE_TYPE xReturn;

/* Add the idle task at the lowest priority. */
xReturn = xTaskCreate( prvIdleTask, ( signed char * ) "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), ( xTaskHandle * ) NULL );
}

static portTASK_FUNCTION( prvIdleTask, pvParameters )
{
/* Stop warnings. */
( void ) pvParameters;

for( ;; )
{
/* See if any tasks have been deleted. */
prvCheckTasksWaitingTermination();

#if ( configUSE_PREEMPTION == 0 )
{
/* If we are not using preemption we keep forcing a task switch to
see if any other task has become available.  If we are using
preemption we don't need to do this as any task becoming available
will automatically get the processor anyway. */
taskYIELD();
}
#endif

#if ( ( configUSE_PREEMPTION == 1 ) && ( configIDLE_SHOULD_YIELD == 1 ) )
{
/* When using preemption tasks of equal priority will be
timesliced.  If a task that is sharing the idle priority is ready
to run then the idle task should yield before the end of the
timeslice.

A critical region is not required here as we are just reading from
the list, and an occasional incorrect value will not matter.  If
the ready list at the idle priority contains more than one task
then a task other than the idle task is ready to execute. */
if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > ( unsigned portBASE_TYPE ) 1 )
{
taskYIELD();
}
}
#endif

#if ( configUSE_IDLE_HOOK == 1 )
{
extern void vApplicationIdleHook( void );

/* Call the user defined function from within the idle task.  This
allows the application designer to add background functionality
without the overhead of a separate task.
NOTE: vApplicationIdleHook() MUST NOT, UNDER ANY CIRCUMSTANCES,
CALL A FUNCTION THAT MIGHT BLOCK. */
vApplicationIdleHook();
}
#endif
}
} /*lint !e715 pvParameters is not accessed but all task functions require the same prototype. */




上一篇:MDK 编译错误总结
下一篇:uCGUI3.98 触摸消息响应过程分析