Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1277370
  • 博文数量: 129
  • 博客积分: 1449
  • 博客等级: 上尉
  • 技术积分: 3048
  • 用 户 组: 普通用户
  • 注册时间: 2012-07-24 18:36
文章分类

全部博文(129)

文章存档

2015年(3)

2014年(20)

2013年(65)

2012年(41)

分类: C/C++

2013-04-15 13:40:13

参数配置   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. */




阅读(2709) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~