Timing difference with actual time and with GPT Timer

Hi Team,


I have taken two GPT timers with one timer 1ms and another 42 seconds timer.

In my application i need to send a command for every 42 seconds with 0 milli second accuracy. I have set a flag in callback and in while(1) loop i'm comparing if flag is set i'm sending the command.

In 1ms call back i'm just doing increment of a variable for comparison of time in milli seconds.


I'm printing log in UART when command has sent, when i compare with 1ms variable count the command is being sent accurately every 42 seconds with 0ms accuracy every time.

But when i take the log and compare with system time i found few milliseconds variation in every command sent. Please help me fixing this issue.


I'm using Renesas S7G2-SK Controller with 1.3.0 SSP, e2 studio. I have 3 threads,

1st - GUI and Touch, (Ticks 10, priority 3)

2nd - three UART's, one pwm control, 1 QSPI, 1 external IRQ, 1 RTC (Ticks 10, priority 2)

3rd - 42sec timer, 1ms timer, one pwm, one ADC (Ticks 10, priority 1)

Only timers (42sec and 1ms) has 0 Interrupt priority, other than all have greater than 0 Interrupt priority.






  • Naresh,

    You should use a semaphore in the callback for the 42sec timer instead of looping and waiting for a flag to change.
    The thread that will send the message should pend on the semaphore that is set in the callback. This thread should have a high priority and should preempt any other running thread.

  • In reply to garyj:

    Thank you Gary for your valuable reply.

    If you have any example for semaphore and preempting the thread could you please share me.

    (I have searched in application and module bundle of 1.3.3 i could not find it.)

  • In reply to Naresh:


    You can create the semaphore in the Synergy configurator by selecting the thread and then add the semaphore by clicking on the New Object button in the Thread Objects window.

    To post a semaphore use:
    tx_semaphore_ceiling_put(&my_semaphore, 1);

    To pend on a semaphore use:
    tx_semaphore_get(&my_semaphore, TX_WAIT_FOREVER);

    This will result in a binary semaphore (state 0 or 1)
    If you want to use a counting semaphore then the put looks like this: tx_semaphore_put(&my_semaphore);

    You can also create a semaphore runtime:
    TX_SEMAPHORE my_semaphore;
    tx_semaphore_create(&my_semaphore, (CHAR *) "My Semaphore", 0);

    This is all documented in the Xware Component Documents for Renesas Synergy which is found on the Synergy SSP download page.

  • In reply to garyj:

    Thank you Gary i'll try the same.