Yahoo Groups archive

Lpc2000

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

Thread

Error reading the ADC

Error reading the ADC

2005-06-10 by soren_t_hansen

I have set up the ADC to run in hardware mode, and is sampling at a
rate of 60 Khz over 4 channels. I use the Keil MCB2130 eval. board,
which means, that I have a Potmeter connected to my AIN0.
But when I read my channel 0 in the interrupt method, I keep getting 0
nomatter what. 

I have the following setup for my ADC:

AD0CR	= 0x0023180F;  //AIN0-3, 9 bits @ 60 kHz (=15 Khz pr. channel)
VICVectCntl0 = 0x00000032;
VICVectAddr0 = (unsigned long)AD_ISR;
VICIntEnable |= 0x00040000;

In my interrupt handler I do the following:

unsigned int val, chan;

val = AD0DR;               /* Read A/D Data Register */
val = (val >> 6) & 0x03FF;	//9 bits - if 10 bits use 0x03FF
chan = ((AD0DR >> 0x18) & 0x07);
result[chan] = val;	//Result is a unsigned int array of size 4
VICVectAddr = 0;		//Reset interrupt	

I then write the result[0] variable to the serial port to see what the
result[0] is and always gets 0.
Has it something to do with my setup of the ADC?

Best Regards
Søren Hansen

Re: Error reading the ADC

2005-06-10 by soren_t_hansen

--- In lpc2000@yahoogroups.com, "soren_t_hansen" <soren_t_hansen@y...>
wrote:
> I have set up the ADC to run in hardware mode, and is sampling at a
> rate of 60 Khz over 4 channels. I use the Keil MCB2130 eval. board,
> which means, that I have a Potmeter connected to my AIN0.
> But when I read my channel 0 in the interrupt method, I keep getting 0
> nomatter what. 
> 
> I have the following setup for my ADC:
> 
> AD0CR	= 0x0023180F;  //AIN0-3, 9 bits @ 60 kHz (=15 Khz pr. channel)
> VICVectCntl0 = 0x00000032;
> VICVectAddr0 = (unsigned long)AD_ISR;
> VICIntEnable |= 0x00040000;
> 
> In my interrupt handler I do the following:
> 
> unsigned int val, chan;
> 
> val = AD0DR;               /* Read A/D Data Register */
> val = (val >> 6) & 0x03FF;	//9 bits - if 10 bits use 0x03FF
> chan = ((AD0DR >> 0x18) & 0x07);
> result[chan] = val;	//Result is a unsigned int array of size 4
> VICVectAddr = 0;		//Reset interrupt	
> 
> I then write the result[0] variable to the serial port to see what the
> result[0] is and always gets 0.
> Has it something to do with my setup of the ADC?
> 
> Best Regards
> Søren Hansen

Solved the problem myself. It turned out that it was yet another error
in the Keil/Hitex documentation. The Pot1 isn't connected to the AIN0
but the AIN1 - therefore it helps a lot taking result[1] instead of
result[0]
Also I seemed to be missing a PINSEL1 |= 0x01000000; due to another
misguiding comment in the Keil example code.

Sorry for the inconvenience

Best Regards
Søren

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.