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

S110 Soft Device and Analog Inputs

I have an application that reads an nRF51822 pin configured as analog input and then sends that value using "ble uart" (included in Nordic's sdk). Analog input is read in an interrupt 250 times per second, but only a few of those values are sent from my main loop (not from interrupt). However, when the connection is established, the analog input stops working but just gives a fixed value (218).

The problem can be solved by initializing analog input in my main loop all the time as follows:

nrf_adc_init(ADC_RES_10bit, ADC_INPUT_AIN3_P02, ADC_INT_DISABLED);

But if I do so, then the BTLE connection hangs up within a half a minute, and actually the whole system probably crashes.

How should I handle ADC when using soft device? Is the soft device using ADC in some way?

Parents Reply
  • Hi Jarmo

    Yes, it is somewhat more complicated when using the softdevice. This is mainly because the softdevice and the application share the same CPU. Softdevice operations generally have higher priority than the application in order to maintain the BLE protocol. Therefore, when doing periodic events in the application, you must be aware of how the BLE connection events work and how the softdevice blocks the CPU during a connection event. so that the softdevice and the application can effectively utilize the CPU together. Periodic application events are typically ADC sampling or SPI/UART/TWI communication.

Children
No Data
Related