Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

No result for ADC in burst mode

No result for ADC in burst mode

2006-02-01 by scrappystuff64

I have this code for the ADC in burst mode. The ISR is called 
continually, but I don't see a value for the result. Gurus enlighten 
me, what am I doing wrong?


#include <lpc21xx.h>

void AD_ISR (void) __irq
{
  unsigned val,chan;
  static unsigned result[8];
  val = ADDR;
  chan = ((val >>0x18) & 0x07);
  val =  (val >> 6) & 0x03FF; //Extract the A/D result
  result[chan] = val;
  VICVectAddr = 0; //clear the IRQ function address
}								
							
	                 

int main(void)
{
  PINSEL1 = 0x003FF000;
  PINSEL0 = 0x03F00000;
  
  ADCR = 0x00270204; // Setup A/D: 10-bit AIN0 @ 4.2MHz
  VICVectCntl0 = 0x00000032; //connect A/D to slot 0
  VICVectAddr0 = (unsigned)AD_ISR; //pass the address of the IRQ 
into the VIC slot
  VICIntEnable = 0x00040000; //enable interrupt

while(1)
{
;
}
}

Re: [lpc2000] No result for ADC in burst mode

2006-02-01 by Tom Walsh

scrappystuff64 wrote:

>I have this code for the ADC in burst mode. The ISR is called 
>continually, but I don't see a value for the result. Gurus enlighten 
>me, what am I doing wrong?
>
>
>#include <lpc21xx.h>
>
>void AD_ISR (void) __irq
>{
>  unsigned val,chan;
>  static unsigned result[8];
>  val = ADDR;
>  chan = ((val >>0x18) & 0x07);
>  val =  (val >> 6) & 0x03FF; //Extract the A/D result
>  result[chan] = val;
>  VICVectAddr = 0; //clear the IRQ function address
>}								
>							
>	                 
>  
>
Try dumping your code (arm-elf-objdump) or look at the listings file 
(.lst). I think that you will find that the compiler has decided that 
since result[] only has a value put into it and it is otherwise unused, 
it was optimized out (dead code).

TomW

- 
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net, http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------------------------------------------

Re: No result for ADC in burst mode

2006-02-02 by Guillermo Prandi

> since result[] only has a value put into it and it is
> otherwise unused, it was optimized out (dead code).

You can try using the "volatile" modifier to the variable. That 
forces the compiler to modify it even when it doesn't see the 
point. :)

Guille

--- In lpc2000@yahoogroups.com, Tom Walsh <tom@...> wrote:
>
> scrappystuff64 wrote:
> 
> >I have this code for the ADC in burst mode. The ISR is called 
> >continually, but I don't see a value for the result. Gurus 
enlighten 
> >me, what am I doing wrong?
> >
> >
> >#include <lpc21xx.h>
> >
> >void AD_ISR (void) __irq
> >{
> >  unsigned val,chan;
> >  static unsigned result[8];
> >  val = ADDR;
> >  chan = ((val >>0x18) & 0x07);
> >  val =  (val >> 6) & 0x03FF; //Extract the A/D result
> >  result[chan] = val;
> >  VICVectAddr = 0; //clear the IRQ function address
> >}								
> >							
> >	                 
> >  
> >
> Try dumping your code (arm-elf-objdump) or look at the listings 
file 
> (.lst). I think that you will find that the compiler has decided 
that 
> since result[] only has a value put into it and it is otherwise 
unused, 
Show quoted textHide quoted text
> it was optimized out (dead code).
> 
> TomW
> 
> - 
> Tom Walsh - WN3L - Embedded Systems Consultant
> http://openhardware.net, http://cyberiansoftware.com
> "Windows? No thanks, I have work to do..."
> ----------------------------------------------------
>

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.