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?

  • Using TIMERx HW peripherals for normal application timers with millisecond resolution is wasting of power, use RTCx instead. That's the main reason i guess why you don't see that use case anywhere, everyone is using either RTC directly or some library like app_timer from Nordic nRF5 SDK (which can "multiplex" several timers on top of single RTC instance).

  • My question still stands. I understands not to use TIMERx for slow less precision activities. But main question is on the multiple channels in a single TIMERx. Seems like PWM is the main use case for these channels and these channels are not independent channels. independent i.e you cannot setup a channel for 200ms, another for 300ms and another for 400ms and get interrupts every 200ms, 300ms and 400ms. Looks like they are more for sequencing. Is this a correct assumption of the HW feature?

  • 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

Related