I want to use a timer to generate a Manchester data. The fastest data rate is 3.906 K-bit. So I want to generate a timer interrupt once 128 uS. Can anyone guide me how to generate it?
I want to use a timer to generate a Manchester data. The fastest data rate is 3.906 K-bit. So I want to generate a timer interrupt once 128 uS. Can anyone guide me how to generate it?
Use TIMER1 with the Timer driver, call nrfx_timer_init to initialize the driver.
1. Create a timer instance with nrfx_timer_t const timer1 = NRFX_TIMER_INSTANCE(1);
2. Create an event handler for your timer with nrfx_timer_event_handler_t timer_evt_handler(nrf_timer_event_t event_type, void *p_context){}
3. Call nrfx_timer_init(&timer1 , NRFX_TIMER_DEFAULT_CONFIG, timer_evt_handler) to initialize the driver.
4. Set up a Compare event at 2048 ticks of the 16MHz TIMER using nrfx_timer_extended_compare(&timer1, NRF_TIMER_CC_CHANNEL0 , 2048, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK , true). This also clears the TIMER in order to create a free-running timer. Use NRF_TIMER_SHORT_COMPARE0_STOP_MASK for a one-shot timer.
5. Call nrfx_timer_enable(&timer1) to start the timer.
timer_evt_handler will then be called every 128µs.
Remember to enable the TIMER1 in sdk_config.h. The SoftDevice has execution priority and can block the application for a few ms, if you need to not get interrupted for a time use the Timeslot API timing.
See also the Timer Example.
Thank you very much. I'll try it.