This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Two timers with same value

Is it possible to have 2 timers (TIMER3 and TIMER4) with the exact  timer value? 

I need to have two gpios toggeling at a difference time frequency but based on the same clock. How can I update the value of a timer arbitrarly or how can I have two timers with the same value? 

This question is related with: https://devzone.nordicsemi.com/f/nordic-q-a/53417/two-different-cc-timer-for-2-gpio-tasks 

Thanks!

  • Hi 

    Dmitry's suggestion should do what you need. It will ensure that both timers start at exactly the same time. 

    You could also use this method to connect to the CLEAR task of the timers rather than the START task if the timers are running and you just want to reset them to 0. 

    When they are both reset they will obviously have the same value, and will run in sync from there (assuming the PRESCALER setting is identical). 

    Best regards
    Torbjørn

  • Whats is the meaning of this?

    NRF_PPI->CH[0].EEP = (uint32_t) &NRF_EGU0->EVENTS_TRIGGERED[0];

    I added something like this:

    NRF_PPI->CH[7].EEP   = (uint32_t)  &NRF_EGU3->EVENTS_TRIGGERED[0];
    NRF_PPI->CH[7].TEP   = (uint32_t) &NRF_TIMER4->TASKS_CLEAR;

    or should it be?

    NRF_PPI->CH[7].EEP   = (uint32_t)  &NRF_TIMER3->TASKS_CLEAR;
    NRF_PPI->CH[7].TEP   = (uint32_t) &NRF_TIMER4->TASKS_CLEAR;
    

  • Hi

    The whole purpose of the EGU in this example is to allow you to generate a hardware event indirectly from software. 

    The EGU is a relatively simple module that will set a hardware event every time the corresponding task is activated through software. 

    Essentially the NRF_EGU0->EVENTS_TRIGGERED[0] event will fire every time you activate the corresponding task like this:
    NRF_EGU0->TASKS_TRIGGER[0] = 1;

    The reason to do this is to allow the event to be connected to the PPI channel, so that two different tasks can be activated as a result of a single software command, without any delay between them.

    Your suggestion would not work as you are trying to assign a TASK to the event end point (EEP). The EEP is only for events and the TEP registers are for tasks.

    Best regards
    Torbjørn

  • Hello,

    I am glad that I found this post. At the moment I am having exactly the same issue. I need that the TIMER4 uses the same clock source as TIMER3.

    Can you please provide me some code how you integrated Dmitry´s suggestion in the "wireless timer sync" code?
    I would also appreciate if you could let me know, how you actually used the TIMER4?

    Thank you very much in advance.

  • Hi, 

    please create a new ticket to get help with your question. 

    Best regards,
    Kaja

Related