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

How can I use micros() with systick or Timer in nRF51822/ ble_app_beacon example

To do some test, I need micros(). This is the reason why I couldn't use RTC or app_timer.  

When I tried timer example(nRF5_SDK_12.2.0_f012efa\examples\peripheral\), I could use micros well. 

However, it didn't work on ble_app_beacon example even referenced this. When I start debug mode on keil5, the stop point is "hardfalut handler".

is there example code about it? and is there any way to use systick?

am I missing something important things? 

== condition ==

- nRF51822

- SDK12.2.0

- ble_app_beacon example

- Using NRF_LOG

  • Hello,

    Can you check whether nrf_drv_timer_init() returns 0 or something else?

    I suspect that the hardfault is caused by the fact that you use const nrf_drv_timer_t TIMER_LED = NRF_DRV_TIMER_INSTANCE(0); which is already in use by the softdevice.

    Can you try to change this to NRF_DRV_TIMER_INSTANCE(1); Remember to enable TIMER1 in sdk_config.h (#define TIMER1_ENABLED 1).

    Best regards,

    Edvin

Related