Christoph Thurnheer

HCS08 MC13213 ATD does not work

Discussion created by Christoph Thurnheer on Nov 27, 2007
Latest reply on Nov 12, 2009 by Todor Alexandrov
I am trieing to convert a sinus signal and modulate it again using the PWM module... But I never get any values from the ATD.

Here is the code:

void Init_PWM (void){
 
  TPM2C2SC = 0x3C;          
  TPM2C2VH = 0x05;                
  TPM2C2VL = 0xD2;                
 
  TPM2MODH = 0x83;
  TPM2C2SC = 0x3C;
 
  TPM2SC = 0x48;
   


}

void Init_ATD (void){
  ATDPE = 0x01;     
  ATDC = 0xB1;
  ATDSC = 0x40;
}


 union DATA
{
   uint8_t Buffer[2];
   uint16_t digit;
} ATDdata;
 

__interrupt void ATD_ISR(void)
{
 
  /*ATDdata.Buffer[0] = ATDRH;
  ATDdata.Buffer[1] = ATDRL;
  */TPM2C2VH = (ATDRH ^0x80);
  TPM2C2VL = ATDRL ;
  ATDSC = ATDSC;
  //TPM2SC = TPM2SC ^0x80;
}

Outcomes