I) A/D Converter Interrupt - Motorola 68HC12 User Manual

Table of Contents

Advertisement

A to D Converter Interrupt:
Operation
This is similar to the non-interrupt based A/D converter.
having to poll the flag to determine when the A/D cycle has been completed, an
interrupt is generated when the conversion is completed.
In order to make use of the A/D interrupt the ASCIE bit in _H12ADTCTL2 must be set
to 1.
This way, when the conversion is completed the interrupt will be triggered.
The flag is cleared by writing a one to ASCIF in _H12ADTCTL2.
operation is the same as the non-interrupt based A/D converter.
_H12ADTCTL2:
bit 7
bit 6
ADPU
AFFC
Sample Code
This sample code calls the A/D interrupt when the A/D cycle is completed.
_ _mod2_ _ void AtoDInt();
void _ _main()
{
DB12->setUserVector(AtoD, AtoDInt); // set the vector address
_H12ADTCTL2=0x82;
_H12ADTCTL3=0x00;
_H12ADTCTL4=0x43;
_H12ADTCTL5=0x00;
while(1)
{
}
}
_ _mod2_ _ void AtoDInt()
{
DB12->out2hex(_H12ADR0H);
DB12->printf("\n\r");
DB12->out2hex(_H12ADR1H);
DB12->printf("\n\r");
DB12->out2hex(_H12ADR2H);
DB12->printf("\n\r");
DB12->out2hex(_H12ADR3H);
_H12ADTCTL2=0x83;
_H12ADTCTL5=0x00;
}
bit 5
bit 4
AWAI
unused
// turn on ATD and on the interrupt
// don't stop at breakpoints
// Set prescalar (/8) & sample time 8 periods
// check AN0
// infinite loop
// A/D ISR
bit 3
bit 2
unused
unused
// Function prototype
// main program
// print contents of registers
// reset the A/D converter
25
However instead of
The remainder of the
bit 1
bit 0
ASCIE
ASCIF

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents