Hi Leo
I haven't done much work with the ADC but did test it once (using
MC9S12NE64 - I am assuming that it is more or less the same as in
your chip).
Try the following, it may work for you - else use it as a starting
point for your own project.
The ADC is initialised in 8bit mode for a 25MHz bus and the first
conversion is started.
Then the value is read from ADC0 and the next conversion started.
Note that there is a conversion time requirement and I was polling
quite slowly so didn't check any status registers.
Maybe it helps you make your first steps.
Cheers
Mark Butcher
www.mjbc.ch
void fnInitialise ADC(void)
{
// Initialise ADC in 8 bit mode
ATDCTL4 = 0xf3; // 8 bit mode suitable for our bus speed (25MHz)
ATDCTL2 = ADPU; // power up the ADC
ATDCTL5 = 0; // start first conversion
}
unsigned char ucReadADC(void)
{
unsigned char ucADCValue = (ATDDR0H); // read the value
ATDCTL5 = 0; // start next conversion
return ucADCValue ;
}
--- In 68HC12@68HC..., "leoshakeme" <leoshakeme@...> wrote:
>
> Hi,
> I am very new to microcontrollers. I am using a MC9S12DP256C on a
> trainer board. To develop I'm using CodeWarrior and C code. It is
all
> overwhelming.
>
> I am trying to write a program that will compare two voltages and
> depending on which voltage is greater to send a digital signal to
a
> stepper motor controller.
>
> My biggest problem stems from interfacing. I dont know how to
> initialize the ATD to obtain the voltages on pins PAD10 and PAD11
> using C code. Does anyone know a good tutorial or have some sample
> code? I appreciate any help, thank you.
>
>
> Regards,
> Leo
>
Reply by Daniel Friederich●March 3, 20062006-03-03
Did you see the Processor Expert support for this chip?
Create a new project (File->New, select "HC(S)12 Project Wizard")
with
Processor Expert, add two ADC beans to your project, enable "Sharing"
in
the Bean Inspector and pick the right converters and ports, choose an
acceptable conversion time, and it should generate all the code you need
for the ADT interfacing.
Of course, if you want to learn how to set it up, well, then this might
be a bit too easy. Do study their code. And also check the Freescale
pdfs about the ADT.
Daniel
leoshakeme wrote:
> Hi,
> I am very new to microcontrollers. I am using a MC9S12DP256C on a
> trainer board. To develop I'm using CodeWarrior and C code. It is all
> overwhelming.
>
> I am trying to write a program that will compare two voltages and
> depending on which voltage is greater to send a digital signal to a
> stepper motor controller.
>
> My biggest problem stems from interfacing. I dont know how to
> initialize the ATD to obtain the voltages on pins PAD10 and PAD11
> using C code. Does anyone know a good tutorial or have some sample
> code? I appreciate any help, thank you.
>
>
> Regards,
> Leo
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
Hi,
I am very new to microcontrollers. I am using a MC9S12DP256C on a
trainer board. To develop I'm using CodeWarrior and C code. It is all
overwhelming.
I am trying to write a program that will compare two voltages and
depending on which voltage is greater to send a digital signal to a
stepper motor controller.
My biggest problem stems from interfacing. I dont know how to
initialize the ATD to obtain the voltages on pins PAD10 and PAD11
using C code. Does anyone know a good tutorial or have some sample
code? I appreciate any help, thank you.
Regards,
Leo