ADC synchronized read calls, are they really synchronized?

Status
Not open for further replies.

DrM

Well-known member
In the ADC library, synhcronized read calls all seem to contain the following lines or similar,

// start both measurements
adc0->startReadFast(pin0);
adc1->startReadFast(pin1);

What synchronizes the ADC's?
 
Follow up, from the documentation

Code:
bool ADC::startSynchronizedContinuous 	( 	uint8_t  	pin0,
		uint8_t  	pin1 
	) 		

Starts a continuous conversion in both ADCs simultaneously.

But in the source code for this function in ADC.cpp, we find

Code:
    adc0->startContinuous(pin0);
    adc1->startContinuous(pin1);

I'm sorry folks, that IS NOT "SIMULTANEOUS". Drive these inputs from a signal generator set close to the sampling rate and you will see that it is not true. And, in a system with a high interrupt rate, it will be irreproducible as well,.
 
True synchronized readings aren't available on this hardware. But you can get something much closer and not distorted by interrupts when using dynamic DMA reconfiguration as explained in the Kinetis Application note AN4590.
 
I think that this suggestion is self understanding and common sense, manitou. The problem seems to be that DrM is using the ADC library which is for sure a nice and helpful piece of software. But without looking at its source code and without understanding how it works you can't be sure of whatever. That's why I, if I had such a timing critical approach, would rather write my own code, writing directly the PDB and ADC registers to make sure that I'm in control of every single detail.
 
Yes, but it seems clear now that the best route is going to be to work with the chip directly and not use the libraries. I may continue with the library as a stop gap, until i finish building up some boards, and then have at it, i.e. write a new low level library for high performance data acquisition.

I started perusing the chip documentation. The description of the ADC seems okay, The section on the interrupt handling seems incomplete. It points to another manual, but the reference is incorrect, and you have to find your way to a third document to find the register set and functionality for the interrupt framewotk. And, I haven't dug into the PDB yet. Those three pieces seem like the starting point.
 
To manitou, that is a fantastically useful link. thank you

And to Theremingenieur, yes, that is exactly what I plan to do. again, thank you

I'll likely switch to the ADC library from the default adc support, for the meantime, and then have at it after i clear some other tasks from my queue
 
Yes, I saw that, it might provide some useful examples for the setups, but it has a lot more going on. my first impression is that it might be easier to just read the hardware manuals.
 
It worked out. By hand coding the ADC, using default settings and both ADC0 and ADC1, two channels can be sampled together at 1.1 MHz. That should be plenty fast enough for what I need to do. I still need to check that the values are correct. they numbers though look what might be expected.

Thank you for your patience and inputs.
 
Status
Not open for further replies.
Back
Top