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

Timer doesn't work with two compare events in 52832

Hi, all,

I confuse with the function of shortcuts register  while I'm using timer with two compare events in 52832.

In main() , I use API: nrfx_timer_extended_compare to configure two CC registers without enabling interrupt

nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
err_code = nrf_drv_timer_init(&TIMER_PWM, &timer_cfg, timer_pwm_event_handler);
APP_ERROR_CHECK(err_code);
nrfx_timer_extended_compare(
&TIMER_PWM,
NRF_TIMER_CC_CHANNEL0,
nrf_drv_timer_ms_to_ticks(&TIMER_PWM, PWM0_CHANGE_INTERVAL),
NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK,
false);

nrfx_timer_extended_compare(
&TIMER_PWM,
NRF_TIMER_CC_CHANNEL1,
nrf_drv_timer_ms_to_ticks(&TIMER_PWM, PWM1_CHANGE_INTERVAL),
NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK,
false);

Then I want to enable CHANNEL0 interrupt  while CHANNEL1 is always disabled and start timer

    nrfx_timer_compare_int_disable(&TIMER_PWM, NRF_TIMER_CC_CHANNEL1);
    nrfx_timer_compare_int_enable(&TIMER_PWM, NRF_TIMER_CC_CHANNEL0);
    nrfx_timer_enable(&TIMER_PWM);

As a response, the timer doesn't work.

But what confused me, when I changed the codes and the timer works

    nrf_timer_shorts_disable(TIMER_PWM.p_reg, NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK);
    nrf_timer_shorts_enable(TIMER_PWM.p_reg, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK);
    nrfx_timer_compare_int_disable(&TIMER_PWM, NRF_TIMER_CC_CHANNEL1);
    nrfx_timer_compare_int_enable(&TIMER_PWM, NRF_TIMER_CC_CHANNEL0);
    nrfx_timer_enable(&TIMER_PWM);

Maybe I can't set COMPARE1_CLEAR even if COMPARE1 interrupt is not be enabled, but I don't find anything about this in nRF5 SDK v15 document.

Can someone provide me something about this?

Thank you!

Corey

Parents Reply Children
No Data
Related