# Micrium Rtos - OSTimeDly not working

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>

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);
}
(void           *)0,
(OS_PRIO         )5,
(CPU_STK_SIZE)1000/10,
(CPU_STK_SIZE)1000,
(OS_MSG_QTY  )0,
(OS_TICK         )0,
(void             *)0,
(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);
}
}
{
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);
}
}


My compiler is Keil.

• You have defined your problem, could you also provide a specific question to make it easier for people to answer your post? This is a Q&A site. Thanks – Voltage Spike Aug 18 '16 at 19:28
• My guess would be that the delay function is based on a timer interrupt. Are you sure that those interrupts are occurring? If they aren't, that would explain why only nonzero delays fail. – Dave Tweed Aug 18 '16 at 19:33
• You should probably specify which version of the RTOS you are using. – user2943160 Aug 18 '16 at 23:57
• @laptop2d I tried to consider your comment in my question and it is edited.Thank you – Nima Aug 19 '16 at 0:16