Peter Molcany

ADC ISR problem on MPC5604B using CW for MPC55xx and MPC56xx 2.9

Discussion created by Peter Molcany on Jan 25, 2012
Latest reply on Mar 26, 2012 by Ravikumar Nanjaiah

Hi!

 

I've been stuck for several days and simply cannot solve the problem.

Here is initialization of ADC.

 

void initADC(void) {ADC.MCR.R = 0x00000000; /* Initialize ADC one shot mode*/ADC.NCMR[0].R = 0x00000007; /* Select ANP1:2 inputs for normal conversion */ADC.CTR[0].R = 0x00008606; /* Conversion times for 32MHz ADClock */}

 init of interrupt

 

//initialization of interruptvoid init_ADC_int(void){ADC.IMR.B.MSKEOC = 1; /*Interrupt Mask bit End Of Conversion*/ ADC.CIMR[0].B.CIM0 = 1; /*Channel Interrupt Mask bit*/}

 and in the main I call functions above plus

INTC_InstallINTCInterruptHandler(ADC_vect, 62, 1);

 in forever loop I start single conversion

if(BUTTON2_PRESSED)// button 2 pressed receive command { ADC.MCR.B.NSTART=1;       /* Trigger normal conversions for ADC0 */ while (ADC.MSR.B.NSTART == 1) {};}

 However interrupt routine never performs

 

When I put this piece of code in main loop it works, but it's not an interrupt

if(ADC.ISR.B.EOC==1) /*Check for End Of Conversion Flag */ ADC_vect();/*ADC interrupt routine*/

 

Please point me to the right direction I have spent so much time and need to get this working.

 

And the last thing, from example it says:

ADC.NCMR[0].R = 0x00000007;

But how can I write 0x7; ->bit 0,1 and 2 to register(seems it's accessible from bit 16-31). If I want CH0 CH1 CH2 shouldn't I rather set  bit 31, 30 and 29 according to bit table in 'MPC5604B/C Microcontroller Reference Manual' page 760? And thus

ADC.NCMR[0].R = 0xE0000000;

 

Thanks for reply

Outcomes