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

nrfx_saadc_irq_handler not getting triggered

Hi ,

I am using saadc to measure battery voltage i m using the sample example given as reference ble_app_proximity/

I am doing adc_configuration in one file and triggering nrf_drv_saadc_sample() from different file in this case alone  nrfx_saadc_irq_handler is not getting triggered

if i call the nrf_drv_saadc_sample() from same file everything is working fine.

Could you help me identify why this is happening?

SDK version  15.2

nRF52840

  • john.ashok said:

    I have configured the priority like below

    #define NRFX_SAADC_CONFIG_IRQ_PRIORITY 6 

    #define BLE_BAS_BLE_OBSERVER_PRIO 2

    Please see the Interrupt Priority section of the SoftDevice specification for details about the available priority levels.

    john.ashok said:
    nrf_drv_saadc_sample() also returns success but event handler is not triggered at all 

    That is good. Could you confirm for me that you have added an APP_ERROR_CHECK to all error codes returned by NRF5 SDK functions?

    john.ashok said:
    as you said if i call this adc_configure()  and nrf_drv_saadc_sample()  other than bas event it works

    Thank you for mentioning this, this is very helpful for the debugging.

    john.ashok said:

    Also after configuring and reading my first ADC sample if i call nrf_drv_saadc_sample()  in bas event it works as expected the adc event is getting triggered

    whether the priority issue comes only for first sample? 

    By this, do you mean that it works as expected if you moved the adc_configure function call outside of the BAS event, and then just called _sample as part of the BAS event handler?
    Did you change the waiting while() loop in the BAS event handler, or implement the waiting differently?

    Best regards,
    Karl

  • Could you confirm for me that you have added an APP_ERROR_CHECK to all error codes returned by NRF5 SDK functions?

    Yes i have used APP_ERROR_CHECK 

    By this, do you mean that it works as expected if you moved the adc_configure function call outside of the BAS event, and then just called _sample as part of the BAS event handler?

    I have moved adc_configure outside BAS event and first call of _sample is also done outside BAS event.

    after that if i call _sample in BAS event it works fine.

    But if i call _sample in BAS event without calling it before it hangs(event not getting triggered)

    means first call of _sample has to be somewhere outside BAS event

    i m sure about the why it behaves like that 

    Did you change the waiting while() loop in the BAS event handler, or implement the waiting differently?

    No, for now waiting while() loop is still there

  • john.ashok said:
    Yes i have used APP_ERROR_CHECK
    john.ashok said:
    No, for now waiting while() loop is still there

    Thank you for confirming this.

    john.ashok said:

    I have moved adc_configure outside BAS event and first call of _sample is also done outside BAS event.

    after that if i call _sample in BAS event it works fine.

    But if i call _sample in BAS event without calling it before it hangs(event not getting triggered)

    means first call of _sample has to be somewhere outside BAS event

    i m sure about the why it behaves like that 

    Strange indeed - especially with the low priority assigned to the SAADC.
    Are you certain that 

    To avoid this being an issue at all you may instead link the TASKS_START or TASKS_SAMPLE to your BAS event using PPI. I would recommend that you do so regardless of this issue, since the sampling then will not require CPU interference for each sample taken. In other words, this will allow sampling to continue regardless of what the CPU might be busy with - such as maintaining BLE connections.
    Would this be something you could consider implementing in your project?

    Best regards,
    Karl

  • Thanks Karl for supporting me

    My issue got resolved as you mentioned

    I recommend that you do not make these kinds of while waiting loops within event handlers, it is not an advisable practice.

    I removed the waiting loops in my application and it works as expected now.....Slight smile

  • john.ashok said:

    Thanks Karl for supporting me

    My issue got resolved as you mentioned

    No problem at all, I am happy to help and glad to hear that your issue has been resolved! :) 

    john.ashok said:
    I removed the waiting loops in my application and it works as expected now....

    That is great! The waiting time can be used in either a low-power SYSTEM ON state, or doing something else, so this is good to hear!
    You could also as mentioned have the sampling trigger by linking their TASKS to an appropriate event through PPI - this is highly advisable.

    Please do not hesitate to open a new ticket if you should encounter any issues or questions in the future.

    Good luck with your development!

    Best regards,
    Karl

Related