Hi,
File "nrf_drv_config.h" defines both TIMER1_CONFIG_BIT_WIDTH and TIMER2_CONFIG_BIT_WIDTH as "TIMER_BITMODE_BITMODE_16Bit", can these timers be configured as 24 bit / 32 bit timers as well?
I am asking because after changing TIMER1_CONFIG_BIT_WIDTH to "TIMER_BITMODE_BITMODE_32Bit", it's not trigger the interrupt handler after 1 second.
Supposedly, 32 bit and 16 Mhz should be sufficient for 1 second interrupt (Timer0 works using the same settings)
Here's the code snippet that is not working: (Borrowed from timer example code from Keil pack installer)
#if (TIMER1_ENABLED == 1)
#define TIMER1_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
#define TIMER1_CONFIG_MODE TIMER_MODE_MODE_Timer
#define TIMER1_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_32Bit
#define TIMER1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
#define TIMER1_INSTANCE_INDEX (TIMER0_ENABLED)
#endif
const nrf_drv_timer_t TIMER_STOP = NRF_DRV_TIMER_INSTANCE(1);
uint32_t time_stop = 1000;
err_code = nrf_drv_timer_init(&TIMER_STOP, NULL, timer_stop_event_handler);
APP_ERROR_CHECK(err_code);
time_stop_ticks = nrf_drv_timer_ms_to_ticks(&TIMER_STOP, time_stop);
nrf_drv_timer_extended_compare(
&TIMER_STOP, NRF_TIMER_CC_CHANNEL1, time_ticks, NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK, true);
nrf_drv_timer_enable(&TIMER_STOP);
Also, what is the preferable way of configuring timer? Some answers on this forum suggest to manipulate the Timer construct directly, like the following:
Last question: The timer construct shows each timer can have 4 CC, then I assume for each timer, I can use nrf_drv_timer_extended_compare with "NRF_TIMER_CC_CHANNEL0", "NRF_TIMER_CC_CHANNEL1", "NRF_TIMER_CC_CHANNEL2" and "NRF_TIMER_CC_CHANNEL3"?
Thanks