Hello,
I am working with nRF5 SDK v17.1.0 and using nRF52832DK board. I want to use the hardware timer in continuous mode and also want to use all 6 compare channels of the timer. But I am only able to get interrupts for 0 to 3 compare channels i.e for only 4 compare channels. My code is below
void timer_init()
{
uint32_t time_ms = 50, time = 0;
nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
err_code = nrf_drv_timer_init(&TIMER_TEST, &timer_cfg, timer_event_handler);
APP_ERROR_CHECK(err_code);
time = nrf_drv_timer_us_to_ticks(&TIMER_TEST, time_ms);
nrf_drv_timer_extended_compare(
&TIMER_TEST, NRF_TIMER_CC_CHANNEL0, time, 0, true);
time = nrf_drv_timer_us_to_ticks(&TIMER_TEST, time_ms + 15);
nrf_drv_timer_extended_compare(
&TIMER_TEST, NRF_TIMER_CC_CHANNEL1, time, 0, true);
time_ms += 50;
time = nrf_drv_timer_us_to_ticks(&TIMER_TEST,time_ms );
nrf_drv_timer_extended_compare(
&TIMER_TEST, NRF_TIMER_CC_CHANNEL2, time, 0, true);
time_ms += 50;
time = nrf_drv_timer_us_to_ticks(&TIMER_TEST,time_ms ) ;
nrf_drv_timer_extended_compare(
&TIMER_TEST, NRF_TIMER_CC_CHANNEL3, time, NRF_TIMER_SHORT_COMPARE3_CLEAR_MASK, true);
nrf_drv_timer_enable(&TIMER_TEST);
}
void timer_event_handler(nrf_timer_event_t event_type, void* p_context)
{
switch (event_type)
{
case NRF_TIMER_EVENT_COMPARE0:
{
printf("NRF_TIMER_EVENT_COMPARE0 \n");
}break;
case NRF_TIMER_EVENT_COMPARE1:
{
printf("NRF_TIMER_EVENT_COMPARE1 \n");
}break;
case NRF_TIMER_EVENT_COMPARE2:
{
printf("NRF_TIMER_EVENT_COMPARE2 \n");
}break;
case NRF_TIMER_EVENT_COMPARE3:
{
printf("NRF_TIMER_EVENT_COMPARE3 \n");
}break;
}
}
The above code is working fine. But when I just add NRF_TIMER_EVENT_COMPARE4 in init and in IRQ, I have the below observations:
1. Not getting interrupt for NRF_TIMER_EVENT_COMPARE4
2. for CC0, CC1, CC2, and CC3 I get interrupted only once (not getting continuous)
Please help to enable CC4 & CC5 and let me know what corrections need to be done in the code so that my timer will work in continuous mode for all 6 compared channels.
Best Regards,
Sanket Chadawar