Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] uVision4 MDK LPC2138 ADC Burst mode not generating interrupt

Status
Not open for further replies.

prerak

Newbie level 4
Joined
Dec 16, 2011
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,320
Dear Experts,

I am trying to execute LPC2138 ADC in burst mode with interrupt, and here is my code:
Code:
int data0, data1;
__irq void intAdc(void){
	int ad = AD0DR;
	
	int channel = (ad >> 24) & 0x7;
//	AD0CR &= ~(0x1 << 16);
//	AD0CR &= ~(0x1 << 21);
	if(channel == 0){
		data0 = (ad >> 6) & 0x3ff;
	} else if(channel == 1){
		data1 = (ad >> 6) & 0x3ff;
	}
	//AD0CR |= 0X1 << 24;
	//AD0CR = AD0CR;
	
//	AD0CR |= 0x1 << 16;			// Burst
//	AD0CR |= 0X1 << 21;			// operational
	AD0DR &= ~(0x1 << 31);
	VICVectAddr0 = 0x0;
}

void initAdc(void){
	// enable ad0.0 and ad0.1 in burst mode
	// the values should be read by the above interrupt
//	AD0CR = 0x0;
//	AD0CR |= 0x3;				// 0 and 1
//	AD0CR |= 13 << 8;			// @4 MHz
//	AD0CR |= 0x1 << 16;			// Burst
//	AD0CR |= 0x0 << 17;			// clks = 0
//	AD0CR |= 0X0 << 20;			// reserved
//	AD0CR |= 0X1 << 21;			// operational
//	AD0CR |= 0X0 << 22;			
//	AD0CR |= 0X1 << 24;
//	AD0CR |= 0X0 << 27;
	
	AD0CR = 0x00211D03;

	VICVectAddr2 = (unsigned int) intAdc;
	VICVectCntl2 = 0x20 | 18;
	VICIntEnable |= 0x1 << 18;
	
//	PCONP |= 0x00001000;
//	AD0INTEN = 0xff;
	//ADGSR |= 0x1 << 16;
}

The code causes the interrupt to fire once, and then never again.
The DONE and the OVERRUN bits are asserted since the interrupt is not called and AD0DR is no longer read.
What am I missing here?
Your help is greatly appreciated!
Thanks,
Prerak
 

I have found the problem.
At the end of the ISR, I was stupidly doing VICVectAddr0 = 0 instead of VICVectAddr = 0.
After correcting that, it works fine.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top