ADC Channels

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ADC Channels

Jump to solution
2,668 Views
amassa
Contributor II

Are there registers ADCx_Rn and ADCx_SC1n for each channel in the ADC0 and ADC1, where n denotes the channel?  I'm confused as to how the different channel registers are accessed.

I am planning on using 9 (or more for future stuff) ADC channels. I see in the example code (adc_demo) ISR code the reading of the SC1A or SC1B registers to determine which ADC channel completed it's conversion. Here's the code:

if (( ADC1_SC1A & ADC_SC1_COCO_MASK ) == ADC_SC1_COCO_MASK)

{ // check which of the two conversions just triggered

  result1A = ADC1_RA; // this will clear the COCO bit that is also the interrupt flag

}

else if (( ADC1_SC1B & ADC_SC1_COCO_MASK ) == ADC_SC1_COCO_MASK)

{

  result1B = ADC1_RB;

}

For my case using more than 2 channels, would I need code similar to this to determine the ADC conversion complete interrupt?

// check ADC1 channel 4

if ((ADC1_SC1(CH4) & ADC_SC1_COCO_MASK ) == ADC_SC1_COCO_MASK)

{

  result4 = ADC1_R(4);

}

// check ADC1 channel 5

if ((ADC1_SC1(CH5) & ADC_SC1_COCO_MASK ) == ADC_SC1_COCO_MASK)

{

  result5 = ADC1_R(5);

}

// check ADC1 channel 6

if ((ADC1_SC1(CH6) & ADC_SC1_COCO_MASK ) == ADC_SC1_COCO_MASK)

{

  result6 = ADC1_R(6);

}

and so on.  I assume there is no way to have an individual channel interrupt (an interrupt per ADC channel).  Is there only a single interrupt per ADC?

Thanks.


Labels (1)
1 Solution
1,421 Views
ndavies
Contributor V

These ADCs don't have the capability to scan through all the connected channels in one conversion. The input channels are muxed into the ADC, So you need to set the ADCx_Rn register to the channel number you want to convert, Run the conversion, read the results and then Set the other ADCx_Rn in that ADC to the next channel to be converted. The next conversion can then  be triggered. You have to tell each conversion the input channel it is to convert.

There are 2 ADCx_Rn register per ADC convertor to allow you to load up the following ADC conversion before you read the current results. A read of the ADC result register can trigger the next ADC conversion.

There was an app note that appeared yesterday that will allow you to scan the ADC input channels using 2 DMA channels.

http://cache.freescale.com/files/32bit/doc/app_note/AN4590.pdf?fpsp=1&WT_TYPE=Application Notes&WT_VENDOR=FREESCALE&WT_FILE_FORMAT=pdf&WT_ASSET=Documentation

View solution in original post

2 Replies
1,422 Views
ndavies
Contributor V

These ADCs don't have the capability to scan through all the connected channels in one conversion. The input channels are muxed into the ADC, So you need to set the ADCx_Rn register to the channel number you want to convert, Run the conversion, read the results and then Set the other ADCx_Rn in that ADC to the next channel to be converted. The next conversion can then  be triggered. You have to tell each conversion the input channel it is to convert.

There are 2 ADCx_Rn register per ADC convertor to allow you to load up the following ADC conversion before you read the current results. A read of the ADC result register can trigger the next ADC conversion.

There was an app note that appeared yesterday that will allow you to scan the ADC input channels using 2 DMA channels.

http://cache.freescale.com/files/32bit/doc/app_note/AN4590.pdf?fpsp=1&WT_TYPE=Application Notes&WT_VENDOR=FREESCALE&WT_FILE_FORMAT=pdf&WT_ASSET=Documentation

1,421 Views
amassa
Contributor II

Thanks for the reply.

So, the ADCH bits in the ADCx_SC1A (where x is the ADC -- 0 or 1) registers need to be changed in the main loop to the next channel that the conversion is to be performed.  Then in the ISR, the reading of ADCx_RA has the conversion value.

In my case, using say 9 channels, I would change the ADCH bits to go from channel 1 - 9 in the main loop and then loop back again.  The ISR would handle reading the ADCx_RA conversion values.

And the same goes for using the ADCx_SC1B and ADCx_RB registers.  I guess I'm still a little confused on if I would need to use the B registers or not.

I would still be using the PDB to trigger the conversion (and keep a cycle time between conversions).  This would trigger the next channel's conversion, right?

Thanks for any input/clarification, greatly appreciated.