help configuring ADC

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

help configuring ADC

1,053 Views
dapuello
Contributor I
hello everybody. this is my first time in this forum recently i bought a demoqe128 module for a project but i have some issues configuring the adc for reading a channel (AD0)and then another channel(AD1) i will appreciate your help with a small example for guidance... thanks for your help
Labels (1)
0 Kudos
3 Replies

459 Views
FWFan
Contributor III

Hi Dapuello,

 

Try searching for QE128QRUGSW.zip.

It has all the peripherals demo codes.

I learned a lot from those demos.

 

Good Luck.

0 Kudos

459 Views
dapuello
Contributor I

thanks

0 Kudos

459 Views
David_UCT
Contributor III

Hi

 

I'm assuming here that you have configured your ADC in software polled mode in single conversion not continuous conversion. 

 

To initiate a conversion you write to ADCSC1.

 

More specifically you need to change the last 5 bits of the register the ADCH section.  These last five bits select the ADC channel that you wish to convert from.  This information may be found on page 222 of the MCF51QE128 reference manual.

 

Your program structure would be something like the following:

 

#Configure your ADC module in single conversion software polled mode and select AD0 and AD1 in your pin control registers.

 

#Change the value of ADCSC1 to the convert the relevant channel.

 

#Wait for the COCO flag to be set for the conversion to be completed.

 

#Read the data out of the Data registers

 

you could use interrupts instead but this is just a simple example.

 

If you would like some C code to demonstrate please ask.  I also suggest that you read the chapter in your reference manual on your ADC module thoroughly.

 

Regards

 

Dave Wright

 

 

 

 

0 Kudos