Jinho
Jinho

Reputation: 9

Print OSTime in UC/OS-II

Device : F28335 contorolCRAD and Experimenter's Kit - Delfino F28335.

Ported ucos-II.

I use OSTimeGet() function to get OSTime.

But task1 returns '0' everytime and task2 doesn't work.

What is the problem? How to fix this?

App_Task1's priority = 6u
App_Task2's priority = 7u


static  void  App_Task1 (void *p_arg)
{
   (void)&p_arg;
   INT32U t;

    while (DEF_TRUE) {

        t = OSTimeGet();

        printf("Task1 \n");
        printf("OSTime=%lu\n",t);
        OSTimeDly(5);
    }
}

static  void  App_Task2 (void *p_arg)
{
   (void)&p_arg;
   INT32U t;

    while (DEF_TRUE) {

        t = OSTimeGet();

        printf("Task2 \n");
        printf("OSTime=%lu\n",t);
        OSTimeDly(10);
    }
}


output
Task1 OSTime=0

Upvotes: 0

Views: 941

Answers (1)

Roel Balink
Roel Balink

Reputation: 417

It seems that your Systick function isn't running correctly. As I have no experience in the Chip you are using I cannot give you the full answer. But your systick function should contain something like this. This is code from a LPC17xx but something similliar should happen for you

void  OS_CPU_SysTickHandler (void)
{
    CPU_SR_ALLOC();


    CPU_CRITICAL_ENTER();
    OSIntNestingCtr++;                                      /* Tell uC/OS-II that we are starting an ISR             */
    CPU_CRITICAL_EXIT();

    OSTimeTick();                                           /* Call uC/OS-II's OSTimeTick()                          */

    OSIntExit();                                            /* Tell uC/OS-II that we are leaving the ISR             */
}

The OSTimeTick() is used for your OSTimeDly(), OSTimeGet() and the task switching

Upvotes: 0

Related Questions