Hello NXP team!
I need to know what happens regarding the data alignment of the ADC. I have done some tests and I've seen that in order to get the adc data from the regirster I have to consider the alignment AND the bit resolution in order to do the correct mask+shifting in order to get the data.
I've also noticed that if I set the resolution to 8 bit I get some data in the non-significant bits that are probably rubbish and they are not related to the ADC data.
I'm putting an image bellow that shows the adc data alignment in regard with the bit resolution at the PCDR0->CDATA register and at the FIFO1DR->ADC_DATA. I've noticed that the value in those registers are the same.
1. Is the above image correct ?
With resolution 8 bits and right alignment i was expecting to see this:
but instead I've seen this when I debugged the registers:
2. Are the ADC data being readden by making and shifting the registers data ?
3. Which is the correct format that the data are stored inside the registers ? I would like not to use the CPU in order to shift or mask the data because that would render the whole timerTrigg->Bctu->Dma transfer pointless if I have to use the CPU for such a reason.
I've read the ADC, BCU and the AN13413 but I didn't understand how the registers store the ADC data. Bellow are some parts regarding the alignment and the resolution.
Here it seems that the data are shifted according to the selected resolution.
A. This is the code regarding reading data from the ADC
B. This is the code regarding reading data from the FIFO1 of the BCTU
4. How should I handle the data if my assumptions are correct ?
I have to port code and the data are stored in a buffer array with DMA. Should I use right alignment and shift the data before used in the code ? is there anything else that I could try ?
Kind regards,
kyf
Solved! Go to Solution.
Or you may see it otherwise.
RM says that data in the result registers are always 15-bit (although I am not sure why it is stated because user cannot choose 15-bit resolution, only 14-bit)
Right-aligned data occupies *CDR[14:0],
Left-aligned data occupies *CDR[15:1].
For right aligned and
14 bit - 0 bits disappear from right
12 bit - 2 bits disappear from right
8 bit - 6 bits disappear from right
For left aligned and
14 bit - 2 bits (i.e. 16-14) disappear from right
12 bit - 4 bits disappear from right
8 bit - 8 bits disappear from right
If you application cannot use it in this format, you will have to perform shifts SW way or use different alignment.
Hello @davidtosenovjan . Thank you for your reply.
The thing is that when I'm selecting right align the LSB are not cut. For example:
My settings are 12bits resolution + right aligned. After the ADC conversion the MSB (11th bit) of the result is located at bit 13 of the register like the image bellow and not at bit 11 of the register as the alignment settings suggest.
and in order to get the adc data I have to shift them right 3 times in the firmware.
Am I missing something ? Shouldn't the LSB be at bit 0 when I select right alignment settings ?
Kind regards,
kyf
Or you may see it otherwise.
RM says that data in the result registers are always 15-bit (although I am not sure why it is stated because user cannot choose 15-bit resolution, only 14-bit)
Right-aligned data occupies *CDR[14:0],
Left-aligned data occupies *CDR[15:1].
For right aligned and
14 bit - 0 bits disappear from right
12 bit - 2 bits disappear from right
8 bit - 6 bits disappear from right
For left aligned and
14 bit - 2 bits (i.e. 16-14) disappear from right
12 bit - 4 bits disappear from right
8 bit - 8 bits disappear from right
If you application cannot use it in this format, you will have to perform shifts SW way or use different alignment.
It is expected. Result is displayed always with maximum resolution. In case resolution is smaller, then LSB bits are cut (considering right align). With left align it is the same, but from left side.
Here is a screenshot from the registers after a BCTU/Adc measurement.
The bellow image shows a RightAligned data with 8bit resolution.
My main query is: Where are my data stored ? Is my data stored at bit 13-6 ?? or are they somewhere else ?