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

nRF52840 how many compare/capture channels per timer?

There are 6 channels per the SDK (nRF5_SDK_15.3.0_59ac345) and the product spec for nRF52840 but I cannot seem to get channels 4&5 to do a compare or capture.  Using Keil's System Viewer for Timer1, CC[4] & CC[5] are always zero (both after writing a compare value or after a capture)

from "nRF52840_PS_v1.1.pdf"

6.30.5.6 TASKS_CAPTURE[n] (n=0..5)
Address offset: 0x040 + (n × 0x4)
Capture Timer value to CC[n] register

6.30.5.7 EVENTS_COMPARE[n] (n=0..5)
Address offset: 0x140 + (n × 0x4)
Compare event on CC[n] match

6.30.5.14 CC[n] (n=0..5)
Address offset: 0x540 + (n × 0x4)
Capture/Compare register n

from "nrf52840_bitfields.h"

/* Register: TIMER_INTENSET */
/* Description: Enable interrupt */

/* Bit 21 : Write '1' to enable interrupt for event COMPARE[5] */
:
#define TIMER_INTENSET_COMPARE5_Msk (0x1UL << TIMER_INTENSET_COMPARE5_Pos) /*!< Bit mask of COMPARE5 field. */
:

/* Bit 20 : Write '1' to enable interrupt for event COMPARE[4] */
:
#define TIMER_INTENSET_COMPARE4_Msk (0x1UL << TIMER_INTENSET_COMPARE4_Pos) /*!< Bit mask of COMPARE4 field. */
:

from "nrf_timer.h" (if channels 4 & 5 were nto defined then I should get a compile error anyway)

/**
* @brief Timer capture/compare channels.
*/
typedef enum
{
NRF_TIMER_CC_CHANNEL0 = 0, ///< Timer capture/compare channel 0.
NRF_TIMER_CC_CHANNEL1, ///< Timer capture/compare channel 1.
NRF_TIMER_CC_CHANNEL2, ///< Timer capture/compare channel 2.
NRF_TIMER_CC_CHANNEL3, ///< Timer capture/compare channel 3.
#if defined(TIMER_INTENSET_COMPARE4_Msk) || defined(__NRFX_DOXYGEN__)
NRF_TIMER_CC_CHANNEL4, ///< Timer capture/compare channel 4.
#endif
#if defined(TIMER_INTENSET_COMPARE5_Msk) || defined(__NRFX_DOXYGEN__)
NRF_TIMER_CC_CHANNEL5, ///< Timer capture/compare channel 5.
#endif
} nrf_timer_cc_channel_t;

the same is discussed for nRF52810 here https://devzone.nordicsemi.com/f/nordic-q-a/45149/nrf52810---how-many-capture-compares

Related