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

saadc scan output order sdk 12.2.0

The output order of my scanning Saadc is not predictable.

I found two related questions, but they both are for SDK 11 and seem to have been resolved.

devzone.nordicsemi.com/.../

devzone.nordicsemi.com/.../

But they suggest that the order should always be in channel order. I use 3 channels - 0, 1 & 2. but my results come out in every order but that. I noticed that the correct values were appearing in the buffer[2] location, so I swapped the indices, but the order remained the same. I swapped the variable assignment lines in the code and the data swapped, positions, but not in a predictable manner. What was loading into my final variable should have been loading into the first, but it showed up in the second. Now I've set things up as they were originally and the first value is showing up in the second variable, instead of the third as it did when it was setup like this before. I need more control. Right now I have a single buffer that takes 3 samples (from all three inputs) and then calls the even handler to extract the data.

These lines of code extract the data from the buffer:

nrf_saadc_value_t adc_press 	= p_event->data.done.p_buffer[0];															//Raw result from the ADC for pressure - it's a 2's complement 16 bit number.
uint16_t motor_curr 		    = p_event->data.done.p_buffer[1];															//Raw result from the ADC for motor current - it's a 2's complement 16 bit number.
uint16_t amb_temp		        = p_event->data.done.p_buffer[2];															//Raw result from the ADC for ambient tempurature - it's a 2's complement 16 bit number.
					
Related