M52233 ADC

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

M52233 ADC

3,386 Views
hammondsp
Contributor I
Hello,

I'm fairly new to working with the MCF hardware and I'm having trouble getting the analog to digital conversion to work correctly. I have a function generator sending a sinusoidal wave going into the AN0 pin (pin 10 on the board) and put the grounding probe to the ground on the board. I have written code to write values into nearly every writeable register associated with the ADC and run the program and still don't see results. Any advice as to what I could be doing wrong would be appreciated. If it helps, here is the code I currently have written:

#include "mcf52233_adc.h"

void ADC_config(void)
{
// Disables interrupts, sets individual input pins, sets mode to single sequential
MCF_ADC_CTRL1 = 0x4000;
// Sets conversion clock to one sixth system clock
MCF_ADC_CTRL2 = 0x0002;

// Disables zero crossing flag
MCF_ADC_ADZCC = 0x0000;

// Set all samples to be taken from AN0
MCF_ADC_ADLST1 = 0x0000;
MCF_ADC_ADLST2 = 0x0000;

// Disable AN1 - AN7, enable AN0
MCF_ADSDIS = 0b11111110;

// Set the 'Start' bit
MCF_ADC_CTRL1 = MCF_ADC_CTRL1 | MCF_ADC_CTRL1_START0;

// Wait in this loop for the conversion to complete
while(!(MCF_ADC_ADSTAT & MCF_ADC_ADSTAT_CIP))
{
;
}

return;
}

After spinning in the loop for a few seconds in debug mode and checking the MCF_ADC_RSLT0 register as well as the MCF_ADC_ADSTAT register, there is no change. Any help would be appreciated.

-SPH
Labels (1)
0 Kudos
Reply
5 Replies

728 Views
hammondsp
Contributor I
Thanks for the help guys. I was unaware the PANPAR needed to be manipulated for the ADC, I'll give it a try and see what happens.

-SPH
0 Kudos
Reply

728 Views
Beyond
Contributor I
Hello Guys,

I'm fairly new to working with the MCF hardware and I am working on M5213EVB. I try to connect a magnetic sensor to ADC module on the board and transmit the digital signal from ZigBee. From the previous messages, I know I have to set up PANPAR register, but according to reference manual, PANPAR register could be setup to use GPIO function and primary function. I don't understand what is primary function?? Are there any other registers I have to set up? DDRAN? CLRAN? I try to use single-ended, sequencial mode of ADC, so it could convert 12 bit in 6 ADC clocks.

Thanks
0 Kudos
Reply

728 Views
mjbcswitzerland
Specialist V
Hi Beyond

>>I don't understand what is primary function?? Are there any other registers I have to set up? DDRAN? CLRAN?

The register PANPAR configures between GPIO and primary function for each of the 8 input.
A '0' means GPIO function (the default setting) and '1' means primary function, in this case the ADC input function.

The other GPIO controls are not important and can be left unmodified.

Regards

Mark

www.uTasker.com



0 Kudos
Reply

728 Views
mjbcswitzerland
Specialist V
Hi SPH
 
I don't see that you are powering up the ADC using something like MCF_ADC_POWER &= ~(PD0 | PD1 | PD2).
 
 
As a reference here is set up code to enable scanning of all 8 inputs.
 
ADC_CTL2 = SLOWEST_ADC_CLOCK;
ADC_POWER &= ~(PD0 | PD1 | PD2).
PANPAR = 0xff;
ADC_CTRL1 = (ALL_SINGLE_ENDED | ONCE_SEQUENTIAL | START0);
while (ADC_ADSTAT & (CIP0 | CIP1)) {}
 
Results available in ADC_ADRSLT0..7
 
You should be able to work out the bit defines from their names and the register descriptions. This code has been used in projects running M5223X and M5213 so is a working reference.
 
Regards
 
Mark Butcher
 

Message Edited by mjbcswitzerland on 2007-03-2711:37 AM

0 Kudos
Reply

728 Views
SimonMarsden_de
Contributor II
Hi

Did you remember to configure the Port AN pins for their analog input function, rather than GPIO? You need something like:


    MCF_GPIO_PANPAR = MCF_GPIO_PANPAR_PANPAR7 |
                      MCF_GPIO_PANPAR_PANPAR6 |
                      MCF_GPIO_PANPAR_PANPAR5 |
                      MCF_GPIO_PANPAR_PANPAR4 |
                      MCF_GPIO_PANPAR_PANPAR3 |
                      MCF_GPIO_PANPAR_PANPAR2 |
                      MCF_GPIO_PANPAR_PANPAR1 |
                      MCF_GPIO_PANPAR_PANPAR0;



Without this, the analog signals supplied on the pins are never connected to the A/D unit.

Just a thought. Hope this helps


Simon
0 Kudos
Reply