AnsweredAssumed Answered

How to configure HVI0 function in MC9s12vr64?

Question asked by Juejie Wang on Jul 5, 2016
Latest reply on Jul 14, 2016 by Juejie Wang

After i configure the HVI0 function as following code, i can not get the right result from ATD result register ATDDR0.

Please help to finger out mistakes in my code. Thanks very much!

Of course , if you can give some suggestion, that will be best.

 

PTL init:

   //********PTL INIT *********

    DIENL |=  0x02U;  //PTIL0 is set to  analog input

                                    //& PTIL1   are set to Digital Input for Down Switch(PTIIL1)

                                 //PTIL2 & PTIL3 are reserved ;

    PTAL = 0x08U;

    PIRL = 0x03U;

    PPSL = 0x00U;    // Falling edge selected for Active interrupt edge

    PIEL = 0x00U;     //  Interrupt is disabled;  PIFL is interrupt flag

//*************************************

ATD init:

/* PIRL: PIRL3=0,PIRL2=0,PIRL1=0,PIRL0=1 */

  PIRL = 0x01U;                                    

  /* Initialization of the ADC module */

  /* ATDCTL0: WRAP3=1,WRAP2=1,WRAP1=1,WRAP0=1 */

  ATDCTL0 = 0x0FU;                                    

  /* ATDCTL1: ETRIGSEL=0,SRES1=0,SRES0=1,SMP_DIS=0,ETRIGCH3=1,ETRIGCH2=1,ETRIGCH1=1,ETRIGCH0=1 */

  ATDCTL1 = 0x2FU;                                    

  /* ATDCTL3: DJM=0,S8C=0,S4C=0,S2C=1,S1C=0,FIFO=0,FRZ1=0,FRZ0=0 */

  ATDCTL3 = 0x90U;                                    

  /* ATDCTL4: SMP2=0,SMP1=0,SMP0=0,PRS4=0,PRS3=0,PRS2=1,PRS1=0,PRS0=1 */

  ATDCTL4 = 0x05U;                                    

  /* ATDCTL5: SC=0,SCAN=0,MULT=0,CD=0,CC=0,CB=0,CA=0 */

  ATDCTL5 = 0x00U;                                    

  /* ATDCTL2: AFFC=0,ETRIGLE=0,ETRIGP=0,ETRIGE=0,ASCIE=0,ACMPIE=0 */

  ATDCTL2 = 0x00U;     

 

Test codes in main.c:

ATDCTL5 = 0x8bU;

 

i look the result register _ATDDR0_Word in data1 windows of IDE.

It is always feedback result around 500;

 

Thanks very much!

Outcomes