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.

  • Hi,

    Thanks for the clarification.

    The driver doc link points to the non-blocking mode of the SAADC configuration. However, the docs say this: 

    To enable the low power mode, you must specify this option when initializing the driver. You can do it by setting SAADC_CONFIG_LP_MODE to true in the driver initialization configuration structure. When it is enabled, the driver uses less power, but more interrupts are generated. When using this mode, the parameter size of function nrf_drv_saadc_buffer_convert must be a multiple of the number of enabled channels. Otherwise, undefined behavior may occur.

    Which I took to mean that the multiple of input channels, was only required for LP mode.

    I feel that a restructuring of that section of the docs would make this much easier to follow.

    Changing it so the content clearly says "[If running in scan mode, the dma buffer must be a multiple of the number of input channels.]"

    Also I'm not 100% familiar with successive approximation adcs, most of the ones I have dealt with just give me a "raw" value. Can I expect the same behavior from this configuration, or do I need to do any data manipulation to convert successive dma reads?

  • Hi,

    I agree that the documentation need a bit of improvement. Regarding the SAADC samples, you do not need to do any data manipulation other than adjust for the gain. However, you need to make sure that you set an acquisition time that is appropriate for your source (not too short if you have a high source resistance). You can refer to the SAADC electrical specification for details.

Related