Shang Jiang

ADC of MPC5643L

Discussion created by Shang Jiang on Mar 15, 2013
Latest reply on May 13, 2013 by Night Fox

I have bought a TRK-USB-MPC5643L to learn this chip some days ago.

i want to use the adc module to get the temperature through the temperature sensor.Then i initialize the ADC register by using

this code:     ADC_0.MCR.R = 0x2000000;/*Initialize ADC0 for scan mode*/

But when i step to this code,the debugger will get to this text: IVOR1trap: b    IVOR1trap     // IVOR 1 interrupt handler.

Please help me .

this is my all code:

int main(void) {

  volatile int i = 0;

  uint16_t ResultAnalog,ResultDigital,Tem,t;

 

  DisableSoftwareWatchdog();

  InitializeModesAndClock();

  InitializePeriClkGen();

 

  SIU.PCR[23].R = 0x2000;/*Initialize B[7] as AN0*/

  SIU.PCR[24].R = 0x2000;/*Initialize B[8] as AN1*/

 

  ADC_0.MCR.R = 0x2000000;/*Initialize ADC0 for scan mode*/

  ADC_0.NCMR[0].R = 0x00000007;/*selcet AN1 input for convertion*/

  ADC_0.CTR[0].R = 0x00008606;/*Conversion times 18Mhz*/

  ADC_0.MCR.B.NSTART = 1;

 

  while(1)

  {

  while(ADC_0.CDR[1].B.VALID !=1)

  {

 

  }

  t = (uint16_t) ADC_0.CDR[0].B.CDATA;

  ResultAnalog = (uint16_t) ADC_0.CDR[1].B.CDATA;

  ResultDigital = (uint16_t) (5000*ResultAnalog/0x3FF);

  Tem = 100*ResultDigital - 60;

  i++;

  }

 

 

}

 

 

Outcomes