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

SAADC missing event

Hello.

I have a issue about missing NRF_DRV_SAADC_EVT_DONE event in saadc  handler.

setup is 52832, SDK 15.3.0, S332. enable ANT, BLE

for battery, sensor, I use 2 adc channel.

buffer size is 2.

like ' adc_buffer[2][ADC_BUFFER_SIZE] '.

adc interval is 10ms, adc sampling through ppi

app timer start rtc timer for intrrupt ppi , app timer interval is 9ms, rtc interval is 1ms.

routine is below.

app timer handler -> adc & ppi init -> rtc timer start -> timer rasie interrupt to ppi -> sampling ->  saadc handler -> Done event -> get adc value -> do something -> ppi uninit -> adc uninit

most case, it work very well.

however, sometimes it stop and issue error code 8 : already initalize saadc.

so I checked the cause, when the issue happened, Done event is not raise. it was missed. so it didn't process uninit.

for reducing power consumption, try init & uninit repeatly.

I also tried 'uninit' move to main loop. not callback.

even though, it still issue intermittently.

Could you give me advices?

Thank you in advance.

Parents
  • You need to look for the END event, not the DONE event, as the END event signifies that the buffer has been filled and transferred to RAM. The DONE event does not have its interrupt enabled in the driver and will not generate an interrupt. 






  • Thank you.
    I found one more. 

    cause rtc timer interrupt is not working. so saadc sample is not trigger.

    rtc timer interval is 1ms.

    rtc prescaler is 31. (need 1024/s)

    it used nrf_drv_rtc_cc_set(adc_channel, current, current +1, true).

    ex) if current is 0x53, it interrupt count is 0x54.

    is it too tight? 

    thank you

  • BEN_HB said:
    app timer interval is 9ms, rtc timer is 1ms (i used prescaler is 31, it meas 1/1024s, almost 1ms)

    If you include interrupts into this state machine then you will have no guarantee that you will sample every 10ms as both BLE and ANT event will have execution priority.

    If you set your RTC prescaler to zero and use a COMPARE event at 328 ticks you will get a COMPARE event every 328 * 30.51µs = 10.00728 ms. 



  • sorry too late reply.

    1. nrf_drv_rtc_cc_set function, last arguement is false, is it no interrupt, just event and it guarantee to happen event regardless BLE and ANT priority?

    (cause rtc handler there is nothing. no need interrupt. only using adc event for ppi)

    2. also consider use only RTC , without app timer. however, for reducing power consumption, init & uninit every 10ms. So before event is happen, need to init adc.

    adc init -> rtc_cc_set -> rtc event raise -> adc sample -> get value -> adc uninit (need)

    if rtc event -> adc init -> can't sample adc.

    Thank you.

     

    1. Correct.

    2. Why do you need to uninitialize the SAADC between every 10ms sample? What's the difference in current consumption if you unititialize and not? 

  • 1. if prescaler = 0, the timer gap is tiny, so avoid exception from priority execution?

    2. using init & uninit : power is about 315uA, if not uninit, power is about 2.12mA,

                      adc uninit include ppi uninit also.

    init&uninit : using app timer and rtc (8ms + 2ms)

    not uninit : only use rtc. adc init one time when boot. it uninit before sleep. rtc prescaler is 31.

                      rtc start -> rtc event -> rtc interrupt -> rtc restart in rtc handler.

                      get value is normal. issue is power consumption. 2.12mA is too high.

                      my opinion is if not excute uninit adc, ppi use dma, it drain more power.

    setup is same. ble + ant + watchdog + app timer + rtc + adc(using ppi)

    Thank you so much

  • That's quite a big difference in current consumption. 

    If you want a more reliable 10ms sample event I suggest you use the RTC (not the app_timer) with an interrupt priority level of 2(See S132 Interrupt priority levels), set to trigger a compare event at 10ms, where you init the SAADC and manually take one sample with nrfx_saadc_sample. Un-init after each sample and repeat.


Reply Children
Related