I have initialized the Micrium Rtos and there is no error when I compile the project but there is a OSTimeDly function in my code that is not working.
I should notify that when I give the first argument of this function ( related to number of ticks to specify the time delay ) the value of 0 , my task is working well but giving any other value to this argument (500 in my code) , stops the program .
Do I need to activate something else to enable using delay functions ??
Here is my code :
#include <GPIO_LPC17xx.h>
#include <app_cfg.h>
#include <os.h>
static OS_TCB AppTaskStartTCB;
static CPU_STK AppTaskStartStk[1000];
static void AppTaskStart(void *p_arg);
void SysTick_Handler(void)
{
OS_CPU_SysTickHandler();
}
int main(void)
{
OS_ERR err;
GPIO_SetDir(0,20,GPIO_DIR_OUTPUT);
GPIO_PinWrite(0,20,1);
OSInit(&err);
if (err !=OS_ERR_NONE) {
GPIO_PinWrite(0,20,0);
}
OSTaskCreate((OS_TCB *)&AppTaskStartTCB,
(CPU_CHAR *)"App Task Start",
(OS_TASK_PTR)AppTaskStart,
(void *)0,
(OS_PRIO )5,
(CPU_STK *)&AppTaskStartStk[0],
(CPU_STK_SIZE)1000/10,
(CPU_STK_SIZE)1000,
(OS_MSG_QTY )0,
(OS_TICK )0,
(void *)0,
(OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
(OS_ERR *)&err);
if (err !=OS_ERR_NONE) {
GPIO_PinWrite(0,20,0);
}
OSStart(&err);
if(err !=OS_ERR_NONE){
GPIO_PinWrite(0,20,0);
}
}
static void AppTaskStart (void *p_arg)
{
OS_ERR err;
p_arg = p_arg;
CPU_Init();
cpu_freq = 100000000;
cnts = (cpu_freq / OSCfg_TickRate_Hz);
OS_CPU_SysTickInit(cnts);
SYSTICK_InternalInit(10);
SYSTICK_IntCmd(ENABLE);
SYSTICK_Cmd(ENABLE);
GPIO_PinWrite(0,20,0);
while(1)
{
OSTimeDly((CPU_INT16U ) 500,
(OS_OPT ) OS_OPT_TIME_DLY,
(OS_ERR *) &err);
GPIO_PinWrite(0,20,1);
OSTimeDly((CPU_INT16U ) 500,
(OS_OPT ) OS_OPT_TIME_DLY,
(OS_ERR *) &err);
GPIO_PinWrite(0,20,0);
}
}
Please help me to solve this problem.
My compiler is Keil.
Thanks in advance
Best Answer
Open startup_LPC177xx.s Replace PendSV_Handler with OS_CPU_PendSVHandler and SysTick_Handler with OS_CPU_SysTickHandler. Press CTRL+F and use Replace tab to do this with your whole project.
It will work!