Steven Hammond

M52233 ADC

Discussion created by Steven Hammond on Mar 27, 2007
Latest reply on Jan 31, 2008 by Mark Butcher
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

Outcomes