Hello,
I have troubles with the timer interrupt. The code work fine until the timer hit the compare value and then stop.
This is my function for the timer init:
void timer_init(uint32_t periode_ms){
uint32_t time_ticks;
// config timer
nrfx_timer_config_t timer_cfg = {
.frequency = NRF_TIMER_FREQ_500kHz ,
.mode = NRF_TIMER_MODE_TIMER,
.bit_width = NRF_TIMER_BIT_WIDTH_32,
.interrupt_priority = NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY,
.p_context = NULL
};
// init timer
APP_ERROR_CHECK(nrfx_timer_init(&TIMER_LED, &timer_cfg,timer_led_handler));
//transform ms in system ticks
time_ticks = nrfx_timer_ms_to_ticks(&TIMER_LED, periode_ms);
// config timer periode
nrfx_timer_extended_compare(&TIMER_LED, NRF_TIMER_CC_CHANNEL1, time_ticks, NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK, true);
// start timer
nrfx_timer_disable(&TIMER_LED);
nrfx_timer_clear(&TIMER_LED);
nrfx_timer_enable(&TIMER_LED);
}
Here is the handler function:
void timer_led_handler(nrf_timer_event_t ev_type, void* p_context){
bsp_board_led_on(1);
}
In the main function, i have a rudimentary loop to blink another led
int main(void){
log_init();
bsp_board_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS);
gpio_init();
timer_init(1000);
/* Toggle LEDs. */
while (true)
{
nrf_delay_ms(200);
bsp_board_led_invert(0);
}
}
The led 0 blink during approx. 1s and then remains off and the led 1 never turn on.
I'm using the SDK 15.3.0 59ac345 on a nRF52832 on a custom board and developping with ECLIPSE/GCC.