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

Question on multiple channels in timers in nrf52

I am trying to understand the use of multiple channels in the timer. Looks like the use of the multiple channels is for PWM/ sequencing type applications. It is not intended for generating interrupts at specific intervals i.e. channel0 generates an interrupt every 200ms, channel1 generates an interrupt every 300ms and channel2 for every 400ms. Looks like this is not how the channels in the timers are supposed to be used? Is my understanding correct?

Also apart from PWM what other applications can the multiple channels in the timer be used for? Also for the sequence i described above looks like RTC and application timer is the way to go. Is this correct?

Parents
  • Hi

    PWM is a typical use case, yes. With a single timer you can create as many unique PWM pulses as you have CC registers, minus one (the last CC register is typically used to reset the timer, and will determine the PWM frequency).

    You can also use a timer to toggle a pin in a particular pattern, and the more CC register you have the more pin toggles you can queue up before you need to update the registers again. This can be used to implement slower serial protocols such as UART, Midi or IR. The more CC registers you have the longer you can accept being interrupted, and the faster pin toggles you can implement.

    The easy way of creating a repeated interrupt, which is to reset the timer when you reach the CC register, doesn't allow you to create multiple repeating interrupts as you say. Since you reset on the first CC register you never reach the others. Instead you can just allow the timer to run freely, and you would have to continuously increment the CC registers once the interrupts hit.
    This is similar to what the app_timer module does, but as mentioned it uses the RTC timer for lower power consumption.

    Best regards
    Torbjørn

Reply
  • Hi

    PWM is a typical use case, yes. With a single timer you can create as many unique PWM pulses as you have CC registers, minus one (the last CC register is typically used to reset the timer, and will determine the PWM frequency).

    You can also use a timer to toggle a pin in a particular pattern, and the more CC register you have the more pin toggles you can queue up before you need to update the registers again. This can be used to implement slower serial protocols such as UART, Midi or IR. The more CC registers you have the longer you can accept being interrupted, and the faster pin toggles you can implement.

    The easy way of creating a repeated interrupt, which is to reset the timer when you reach the CC register, doesn't allow you to create multiple repeating interrupts as you say. Since you reset on the first CC register you never reach the others. Instead you can just allow the timer to run freely, and you would have to continuously increment the CC registers once the interrupts hit.
    This is similar to what the app_timer module does, but as mentioned it uses the RTC timer for lower power consumption.

    Best regards
    Torbjørn

Children
No Data
Related