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

UART, ADC, BTLE, Timer 1msec

Currently working on an app which will utilize the ADC component of an NRF chip.

The app will use the full bluetooth stack SF132;6.0.0, adc, and will need to have ability to send uart.

First: I need to initialize the ADC for multiple channels and to not be triggered by a timer, but by the app.

Second: BLE will always be advertising/listening for a host device.

Third: UART will stream a small data packet ~10 Bytes, every second or so.

What do I need to do so that I can call the ADC read for all channels?

What would be the best way to get a 1msec tick, not a SysTick as I will need it to work even when the device is asleep.

How should the UART be initialized so that it will run even when the softdevice is handling btle packets?

Thanks.

Parents
  • Hi, 

    The SAADC driver documentation describes how you can trigger ADC sampling. Note that you have to trigger it via PPI if you want to sample all channels in quick succession (continuous mode), but you can still sample each channel only once per time it is triggered (see Scan mode). The most sensible way to trigger sampling every 1 ms is probably using the application timer (See timer library documentation). The SDK does not have any example that shows exactly this, but Jørgen has attached a project (zip file) to this post, which regularly samples two channels to this post. Note that it is for an older SDK and id uses the RTC directly instead of via the timer library, but most of the example should be relevant.

    The nRF52 only has a single CPU, so you cannot necessarily always have the UART peripheral running while the SoftDevice is handling a BLE packet. However, the UART peripheral has DMA support, so you may not need to use the CPU that much. Moreover, you should make sure to use hardware flow control if possible so that you do not risk losing data in case the nRF is not ready to receive data when the other UART device wants to transmit.

Reply
  • Hi, 

    The SAADC driver documentation describes how you can trigger ADC sampling. Note that you have to trigger it via PPI if you want to sample all channels in quick succession (continuous mode), but you can still sample each channel only once per time it is triggered (see Scan mode). The most sensible way to trigger sampling every 1 ms is probably using the application timer (See timer library documentation). The SDK does not have any example that shows exactly this, but Jørgen has attached a project (zip file) to this post, which regularly samples two channels to this post. Note that it is for an older SDK and id uses the RTC directly instead of via the timer library, but most of the example should be relevant.

    The nRF52 only has a single CPU, so you cannot necessarily always have the UART peripheral running while the SoftDevice is handling a BLE packet. However, the UART peripheral has DMA support, so you may not need to use the CPU that much. Moreover, you should make sure to use hardware flow control if possible so that you do not risk losing data in case the nRF is not ready to receive data when the other UART device wants to transmit.

Children
Related