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

gpiote with softdevice in sdk8.1 not work

Hello,all

I want to use timer,ppi and gpiote to toggle a pin in sdk8.1 but not working.Here are details:

Firstly I use the example project "gpiote" which does not contain softdevice, and it works. Then I add the code to my project in sdk8.1 which contain softdevice, it does not work.

things that I know should be changed:

1.Timer0 is used by softdevice, instead it with Timer1 or Timer2. It avoid the HardFault,but the toggle function still not working.

so what else things should I change more? (like changing the "NRF_PPI_RESTRICTED" to 1? Or something else)

Thank you very much!

Parents
  • The reason for this is probably that TIMER1 and TIMER2 is 16 bit, whereas TIMER0 is 32 bit. In the call to nrf_drv_timer_extended_compare(), the third parameter is the compare value. In the example this is 200*1000, which is more than 16 bits, as ceil(log2(200*1000)) = 18. If you change it to 50*1000 instead, you should see the LEDs blink as expected, though four times faster.

    Remember to change TIMER1_CONFIG_FREQUENCY to NRF_TIMER_FREQ_1MHz in nrf_drv_config.h in your project (same as for TIMER0) if you have not already done so, as it NRF_TIMER_FREQ_16MHz by default. You can also set it to NRF_TIMER_FREQ_250kHz, which would result in the same LED blink frequency as you got with a compare value of 200*1000 and the 1 MHz timer.

  • Thank you for your fast reply!

    It is exactly the same as what you said. After setting:

    1.set the third parameter(compare value) of nrf_drv_timer_extended_compare() to less than 65535.

    2.change TIMER1_CONFIG_FREQUENCY to NRF_TIMER_FREQ_1MHz

    the timer runs, and gpiote and ppi also work fine without any change.

    Thank you very much!

Reply Children
No Data
Related