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

Timer is not stable(phase/duty change all the time).

Dears, I am working for an application on [email protected] including PWM, Timer and a few peripheral functions. I was trying to create a timer on timer1 in us tick. The timer was created, but not stable. I implemented a pin toggle in timer even handler to check the timer stability. The only way to get a stable output pin toggle signal is that set the timer priority to 1(original is 3), but it will cause the system crash. Is there any mistake I implemented the timer for us application?


void sTimerInit(void) { uint32_t time_us = 20; //Time(in micro-seconds) between consecutive compare events. uint32_t time_ticks; uint32_t err_code = NRF_SUCCESS;

//Configure TIMER_LED for generating simple light effect - leds on board will invert his state one after the other.
nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
err_code = nrf_drv_timer_init(&TIMER_COUNTER_IR, &timer_cfg, timer_led_event_handler);
APP_ERROR_CHECK(err_code);

time_ticks = nrf_drv_timer_us_to_ticks(&TIMER_COUNTER_IR, time_us);

nrf_drv_timer_extended_compare(
     &TIMER_COUNTER_IR, NRF_TIMER_CC_CHANNEL0, time_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);

nrf_drv_timer_enable(&TIMER_COUNTER_IR);

}

Parents Reply Children
Related