Using SAADC Advanced mode with high sampling rate together with Zephyr ADC

Hello,

I have an application where I want to read the voltage of a battery every 5 minutes for this I'm using the Zephyr ADC library. But now I also want to read the ADC value of a sensor with a high sampling rate of ~2 kHz or higher. I also want to use the limit feature to be notified when the ADC value of the sensor drops below a certain value. For doing this I'm using the NRFX library. I found this example. And modified it to work the way I need it to. Now when I add both the battery measurement and the sensor reading together into one project I get an error that the IQR has been set multiple times:

gen_isr_tables.py: error: multiple registrations at table_index 7 for irq 7 (0x7)
Existing handler 0x387cf, new handler 0x23899
Has IRQ_CONNECT or IRQ_DIRECT_CONNECT accidentally been invoked on the same irq multiple times?

I have done some research and suspect that I cannot use NRFX with the Zephyr ADC driver. So I need to do both with NRFX. Is this assumption correct?

If I configure SAADC to be in the advanced mode, it can not be configured to be in simple mode for a different channel at the same time. Is this the case?

I also looked at this example where multiple channels are sampled simultaneously. This would read both channels at 2 kHz. For this I have to configure the sampling buffer to have enough space to hold the values from both channels, which wastes a lot of memory. And how would this affect the power consumption? I could also switch channels every 5 minutes for one cycle as described here. But this looks a bit too complicated to just read two channels at different intervals.

What would be the best way to solve this problem?

Another question: Will the sampling rate have an effect on the reaction time of the limit being set or are they independent of each other?

Best regards,

Jonas

Parents
  • Hi Jonas,

    You are right, it is not possible to use both the zephyr and nrfx to interface the SAADC, so it is necessary to choose one (nrfx in this case). Also, when using the nrfx driver, you can't use different modes concurrently. That said, given how infrequent the battery measurements are, I don't see a problem with reconfiguring the driver before taking the battery sample, then reconfigure it back to sampling the sensor output provided you don't need to sample continuously at 2k.

    I would expect the current consumption to be around 1.2-2 mA while sampling (depends on supply voltage on whether you are using the LDO or DCDC regulator). 

    Best regards,

    Vidar 

  • Hi Vidar,

    sorry for the late response! I implemented the switching by reconfiguring the driver as you suggested and it works fine.


    Thanks,

    Jonas

Reply Children
No Data
Related