2 months, 2 weeks ago.
How does one independently alter ADC configurations for A0 thru A7 inputs with the nRF51-DK?
I am developing an Environmental Sensor service for BLE using the nRF51-DK on the Nordic nRF51422 IC using Mbed OS2. The service multiplexes several sensors into the ADC for conversion. I need to be able to set the ADC_CONFIG_REFSEL and ADC_CONFIG_INPSEL bits of the NRF_ADC->CONFIG register indepently for each sensor input. Problem is I don't see how to do this while using Mbed's implementation of Analog inputs, e.g.:
<<p>> AnalogIn ana0(A0); // temperature AnalogIn ana1(A1); // pressure AnalogIn ana2(A2); // humidity <</p>>
All my attempts to set the CONFIG registers are getting lost by the time I execute anaX_read(). How is this analog input magic implemented? Is there some way to create a method for configuring the analog inputs? Steve
2 months, 1 week ago.
Your analysis is correct - and on top of that after consulting the nRF51 Reference Manual it appears that the device family doesn't allow for independent configurations for each channel. A single config applies for all channels. So if your channels do need different configurations it looks like you will have to reprogram the ADC and serialize your sampling.
As you noted Mbed doesn't have a function for setting the options you would like, so you can write your own function to handle it.
-Ralph, Team Mbed
To post an answer, please log in.