This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nRF52840 SDK16 - SAADC + RTC + PPI (power optimized solution)

Hi everyone,

There is an open ticket that I need support with because the responsible engineer will be out of the office until the new year.

In a nutshell:

I design a low-power application and I want to sample 8 pressure sensors that are connected to a MUX. I want to sample with a rate of 100Hz the group of eight sensors. That means every 10ms I need to sample all of the 8 sensors as fast as possible (given of course the hardware delays such as the MUX's switching speed and ADC conversion and acquisition time). So far, the optimized approach is to use:

RTC because uses the low-frequency clock

PPI because sampling does not require CPU intervention. However, PPI channels require that the HFCLK is always kept running (so I still thinking about it)

My purpose to go through the MUX's truth table using PPI as well (but in a future step)

Now let's say that I set an RTC CC to 10ms to trigger the SAMPLE task using the COMPARE event. Then, I have to keep sapling until the 8th sensor. I came across with two possible solutions using PPI:

1. To set up a second RTC CC let's say to 50us, to trigger the sample task using the compare event until to sample all the sensors

2. To enable the DONE interrupt, to set up a second PPI channel and trigger the SAMPLE task with the DONE event (I tried to do this but still it hasn't work) until the 8th sensor

Here Karl says that I can achieve the same functionality with just one PPI channel. I do not understand how can I do it with one channel or I didn't explain correctly to Karl what I want to achieve.

Given the aforementioned, what is the most power-optimized approach?

Thanks

Nick

  • why not do the whole thing under RTC Compare event handler ? set the new event at the end of the handler and you wont need to time the whole thing up. And by the way, you can use app_timer for this. App timer uses RTC1 and saadc uses app_timer. An RTC can configure 4 compare event. 1 used by the saadc. you have 3 of them free. you can set a app_timer event(basically compare event) and do the saadc readings in event handler. at the end of the handler you set a new timer and so on. You just remember not to go to sleep in app_timer event handler. it just stucks there. I just discovered it :D you can look into my ticket. I use saadc and app_timer. whole code is not shared but what you need is there. Look at my ticket

  • Hi,

    The suggestion you already got makes sense I would say. Though I would simplify even further and simply us an extra repeated app_timer, which gives you all you need out of the box. This way simply do the SAADC handling from SW, and use a normal system on low power sleep in between.

    The down-side of this approach is that as you do this in SW, a higher priority interrupt would delay your sampling. As you sample every 10 ms (not very often) that is perhaps not a big problem? Also, depending on interrupt priorities and durations of the high priority interrupts you have in the rest of your code, the actual worst case delay will probably be very short compared to the 10 ms interval.

  • Hi Einar,

    So you suggest not using the PPI but just application timers because my sampling frequency is low? This will keep down the power consumption since I won't use PPI I guess?

  • Yes, it will. Not on its own, though. You also need to disable the SAADC (nrf_saadc_int_disable()) when done and re-enable it before using it in order to obtain low power consumption (if not, the SAADC will always be enabled and so the high frequency clock will also always run).

  • Thank Einar,

    So I need two app timers? The first one will expire every 10ms to start sampling with the first sensor and then I need the second app timer to keep sampling the rest 7 sensors right (probably 80-100us it would be fine)? But now I am thinking that 80-100us is fast enough and could be a problem with the higher priority interrupts.

    The requirement is to start sampling every 10ms BUT the sampling between the sensors (8 in total) to be done as fast as possible.

Related