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.

LPC2148 ADC Interrupt problem

Status
Not open for further replies.

vaibhavsharma

Newbie level 4
Joined
Jul 6, 2011
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,321
Hello All,
I am using LPC2148 in one of my application. i just don't want to poll for completion of adc conversion, so i have use interrupt for adc conversion completion. First time (i have checked it in simulator and same situation may occur in harware becuase it not work what i desire) when i tell lpc2148 through command to read adc, it start conversion and interrupt generate and it execute it's adc ISR. but iterrupt (ADINT) is not get clear, even i read all registers (ADDR,ADGDR,ADSTAT), so next time when adc conversion get complete, control not jump to execute ISR.

Please help.
 

Post your code, there in no way for us to understand what you are doing in your code

Alex
 

Below is ADC initialization funciton:
void adc_init(void)
{
AD0CR = 0x0020A000;
AD1CR = 0x0020A000;
VICIntEnable |= (1<<18);
VICVectAddr0 = (unsigned long) ADC0_ISR;
VICVectCntl0 = 0x20 | 18;
VICIntEnable |= (1<<21);
VICVectAddr1 = (unsigned long) ADC1_ISR;
VICVectCntl1 = 0x20 | 21;
AD0INTEN = 0x000000C0;
AD1INTEN = 0x000000C0;
}

Below is ADC ISR:
void ADC0_ISR (void) __irq
{
//VICVectAddr = 0;
if (RxBuffer[1] == 0x01)
{
AD0DR6;
AD0GDR;
AD0STAT;
AD0CR &= 0xFEFFFF00;
}
else if (RxBuffer[1] == 0x02)
{
AD0DR7;
AD0GDR;
AD0CR &= 0xFEFFFF00;
}
}
Below is the piece of code, when i give command through uart, it check the command and start conversion on required adc:
if (RxBuffer[1] == 0x01)
{
switch (RxBuffer[3])
{
case (0x01):
{
AD0CR |= ad_0_7; //select adc_0_6 for conversion
AD0CR |= ad_cnv_strt; //start conversion for selected adc
break;
}
 

The last line of any interrupts should contain the following

Code:
VICVectAddr = 0;   /* Acknowledge Interrupt */

You can also take a look at my application, you may find it useful
https://www.edaboard.com/threads/196143/

Alex
 
But when i place VICVectAddr = 0; in the last line of ISR, then after executing this instruction, it immediately jump to begging of the same ISR. I have checked it in simulator (keil)
 

if you don't use it then you will not get another interrupt, you have to use it.
If you get an immediate interrupt then you are obviously doing something wrong and then done flag is not cleared.
In your coded AD0CR &= 0xFEFFFF00; sets the done flag

Alex
 

It is observed that DONE flag is get cleared but ADINT is not get cleared, even i place VICVectAddr = 0; at the end of ISR. Please help.
 

Not when I tried, for me AD0DR6; AD0GDR; AD0STAT; cleared all the done flags (global and channel) and then in this line AD0CR &= 0xFEFFFF00; the done is set again so you will naturally return into the interrupt.
If I remove AD0CR &= 0xFEFFFF00; everything works fine.

Why are you using this line?

Alex
 

i removed AD0CR &= 0xFEFFFF00; line. plz refer attach snap. still it jump in same routine again just after execution.

---------- Post added at 16:07 ---------- Previous post was at 16:03 ----------

i think snap shot of IDE is not attached.. i am not getting success to attach it after several retries..

---------- Post added at 16:24 ---------- Previous post was at 16:07 ----------

it is solved. i was reading AD0DR6 but start conversion on channal0.7... thank you sir for your help..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top