A silly question about timer register triggers

I'm sorry. This must be trivial to all of you. I'm a beginner with nrf52 programming, and I saw several examples that refer to timers TASK_START, TASK_CLEAR, TASK_STOP. Everywhere, it just sets them to "1". However the datasheet says that it's a trigger operation (edge triggered as I understand it).

So.. What resets the trigger flag then? Is it automatic? After how many clock cycles? I searched in the datasheet and online tutorials but I'm clearly missing the answer.

Thanks in advance.

Parents Reply
  • Hi,

    Thanks for the answer. My question was not general about tasks. It was specific about timers'  TASK_START, TASK_CLEAR, TASK_STOP tasks and what sets their flag back to zero. both of you are giving contradicting answer:

    1. You say that it happens automatically after one clock cycle.

    2. Nguyen says that I must write "0" to EVENTS_COMPARE[X] to reset the triggered events flag (also can happen on it's own when timer's done).

    Which is the correct answer in this specific situation?

    Thanks again

Children
  • Once the compare event happened, it will generate an interrupt. If you don't set it to zero, you'll interrupt continuously.  The counter continues to count since the task is not stopped. After overflow, it will reset to zero and continue to count then reach the compare value again until you set the stop task. 

    Brief, the task is for starting and stopping the counter.

  • Hi Nguyen.

    I've completely lost you there.

    1. For interrupts, I know that if an interrupt has been defined and attached, the compare event must be reset so it doesn't keep calling the interrupts. That was not my question.

    2. I asked about what brings the timer START, STOP, and CLEAR task flags back to 0, after a program sets them to 1, since in the examples that I saw this isn't done explicitly.

    3. As per Elfving when these tasks are executed, the flag goes to 0 automatically one clock cycle later.

    Can you please confirm or contradict? My question has nothing to do with compare or overflow.

    Thanks again

  • TASK_CLEAR = 1 => Resets counter to zero

    TASK_START = 1 => Starts timer counter and runs until TASK_STOP is set to 1. 

    TASK_STOP = 1 => Stops timer counter

  • Hello, 

    matangk said:
    1. For interrupts, I know that if an interrupt has been defined and attached, the compare event must be reset so it doesn't keep calling the interrupts.

    Correct.

    matangk said:

    2. I asked about what brings the timer START, STOP, and CLEAR task flags back to 0, after a program sets them to 1, since in the examples that I saw this isn't done explicitly.

    matangk said:
    My question was not general about tasks. It was specific about timers'  TASK_START, TASK_CLEAR, TASK_STOP tasks and what sets their flag back to zero.

    The value being written there isn't being retained. It just creates a signal. There is info in the product specification about this.

    Regards,

    Elfving

  • Hi Elfving, I think we have concluded as much :)  So unless someone contradicts, I figure that writing 1 to a timer task register creates a single clock cycle pulse.

    Thanks again for the enormous attention and patience,

    Matan

Related