OS_Timing_Getus usage problems

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • OS_Timing_Getus usage problems

    I am trying to measure the time that the CPU is not in the idle loop. I have the following code in my OS_ISR_Tick handler:

    C Source Code

    1. #pragma vector = 5
    2. __interrupt void OS_ISR_Tick (void) {
    3. OS_EnterInterrupt();
    4. if (!timeFlag)
    5. {
    6. OS_Timing_Start(&myT);
    7. timeFlag = eTRUE;
    8. }
    9. OS_TickHandler();
    10. OS_LeaveInterrupt();
    11. }
    Display All




    Then inside of the idle function I have the following:

    C Source Code

    1. void OS_Idle(void) { // Idle loop: No task is ready to exec
    2. for (;;)
    3. {
    4. if (timeFlag)
    5. {
    6. OS_Timing_End(&myT);
    7. timeFlag = eFALSE;
    8. timeStruct.timeBuffer[tbIdx++] = OS_Timing_Getus(&myT);
    9. if (tbIdx > 511)
    10. tbIdx = 0;
    11. }
    12. asm("WAIT"); //enter wait mode
    13. //four NOP instruction required after WAIT
    14. asm("NOP");asm("NOP");asm("NOP");asm("NOP"); // Nothing to do ... wait for a interrupt
    15. }
    16. }
    Display All


    When I try to read the values as they are stored in the buffer, most of the time (99.5%) I get the value "1055" which does not seem correct. I have set a probe on a pin and measured to get 57.6 microseconds. Any advice?