16 bit microcontroller ATD questions

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

16 bit microcontroller ATD questions

2,503 Views
EagleBeak
Contributor I
I would like to ask someone about some particulars of the ATD system on MC9S12E128.
 
I am reading the registers as right justified, 10 bit, unsigned and not getting what I expect.
 
The VCC of the micro is 3V but the VRH and VRL range is 4.0V.
 
I placed 3 volts at the input of a channel  (under emulator control ) but am reading 2.5V.
 
By my calculation I'm about a half a volt off on my readings, though they are fairly consistent.
 
If I ground the input, it reads close to zero most of the time, within 3%.
 
Any suggestions?
 
Thanks,
Eagle Beak
 
 
 
Labels (1)
0 Kudos
4 Replies

511 Views
Vsousa
Contributor I
Hi,

I'm having some troubles with ATD module of the MC9S12E128. I'm using the high chanel and the CH7 as digital IOs and the other pins as analogic inputs. I don't know why, the AN4, AN5 and AN6 operation, doesn't sets the ATDSTAT1 with their corresponding CCFx Flags.
I'm sending a piece of code to show the ATD initialization and using..

----------------------------------------------------------------------
void AdcConfig(void){
     ATDDIEN0 = 0xFF;   // Enable digital ports to PTADHi.
     ATDDIEN1 = 0x80;   // Enable digital ports to PTADLo bit7 and analog to others.
     ATDCTL2  = 0xC0;   // Normal ATD functionality and enable Fast Clear Flag
     ATDCTL4  = 0x21;   // ATD Clock prescaler = Divide by 4 due the max/min clock freq
     ATDTEST1 = 0x00;   // No Special conversion chanel
}

int Adc6(void){
  ATDCTL5 = 0x86;                     // Right justified data in the result registers - turn on ch6
  while (!(ATDSTAT1 & CCF6));   //Wait
  return ATDDR6;
}

int Adc5(void){
  ATDCTL5 = 0x85;               // Right justified data in the result registers - turn on ch5
  while (!(ATDSTAT1 & CCF5));   //Wait
  return ATDDR5;
}

int Adc4(void){
  ATDCTL5 = 0x84;               // Right justified data in the result registers - turn on ch4
  while (!(ATDSTAT1 & CCF4));
  return ATDDR4;
}

int Adc3(void){
  ATDCTL5 = 0x83;               // Right justified data in the result registers - turn on ch3
  while (!(ATDSTAT1 & CCF3));   //Wait
  return ATDDR3;
}

..... until CH0

 The chanels below CH4, works fine and the digital pins too. I don't know what's happening,

Please, If you could help me..

Thank you.

 
0 Kudos

511 Views
DanielM
Contributor III
VRH cannot be above VDDA - read the spec! The allowed range for VRH is from VDDA/2 to VDDA.

BTW, 3V is uder spec limit for VDDA, VDDX and VDDR as well. The minimum supply voltage is 3.135V.

Daniel

Message Edited by DanielM on 2006-09-20 02:47 AM

0 Kudos

511 Views
EagleBeak
Contributor I
Daniel,
I suspected what you said is true but I couldn't find the spec you refer to. Is it in the data sheet?
 
Thanks so much,
Eagle Beak
0 Kudos

511 Views
EagleBeak
Contributor I
Daniel,
 
Woops, I found the spec. Thanks for the quick response to my question. It was a life saver.
 
Eagle Beak, aka Scott
0 Kudos