EmbeddedRelated.com
Forums

errors in my ADC code for LPC2148 (beginner)

Started by lucky_suhas August 27, 2011
Hi,
i have just started learning to use the LPC2148. the code is for using one of the channels in ADC0.i tried compiling my code and there seems to be something wrong. i'm getting an

"Error: C9932E"

in "keil".

the purpose of the code is to see how adc works on this micro-controller.
could anyone tell me what i am doing wrong?
my code is as below:

#include

void init_adc0(void)
{
PINSEL0 = (PINSEL0 & ~(3 << 8)) | (3 << 8)& ~(3 << 10)) | (3 << 10);
PINSEL1=(PINSEL1 & ~(3 << 18)) | (1 << 18)& ~(3 << 24)) | (1 << 24)& ~(3 << 26)) | (1 << 26)& ~(3 << 28)) | (1 << 28);
}

unsigned adc_read(unsigned char ch_no)
{
AD0CR=0x00200000 & (1<
do
{
i = AD0GDR; // Read A/D Data Register
} while ((i & 0x80000000) == 0); // Wait for end of A/D

return ((i>>6) & 0x3FF);
}

void main(void)
{
init_adc0();
resultc_read(2); //ch_no 7:6;4:1
}
one last thing, in the main() i'm just using the 'result' to get the value here because i do not know what else i can do with it. if i am to load my code on to the board what do you suggest i do with the ADC data? i'm just trying to learn so anything you could tell me would be helpful.

Thanks for reading.

An Engineer's Guide to the LPC2100 Series

There should be an explanation after the Error: C9932E, doesn't is say anything else?
You should always use an endless loop, the execution shouldn't be allowed to exit the mail loop, the minimum you should use is a while(1); at the last line of the main function.
You can assign the ADC result to 10 output pins if you want to use it somehow.

Alex

----- Original Message -----
From: lucky_suhas
To: l...
Sent: Sunday, August 28, 2011 1:07 AM
Subject: [lpc2000] errors in my ADC code for LPC2148 (beginner)

Hi,
i have just started learning to use the LPC2148. the code is for using one of the channels in ADC0.i tried compiling my code and there seems to be something wrong. i'm getting an

"Error: C9932E"

in "keil".

the purpose of the code is to see how adc works on this micro-controller.
could anyone tell me what i am doing wrong?
my code is as below:

#include

void init_adc0(void)
{
PINSEL0 = (PINSEL0 & ~(3 << 8)) | (3 << 8)& ~(3 << 10)) | (3 << 10);
PINSEL1=(PINSEL1 & ~(3 << 18)) | (1 << 18)& ~(3 << 24)) | (1 << 24)& ~(3 << 26)) | (1 << 26)& ~(3 << 28)) | (1 << 28);
}

unsigned adc_read(unsigned char ch_no)
{
AD0CR=0x00200000 & (1<
do
{
i = AD0GDR; // Read A/D Data Register
} while ((i & 0x80000000) == 0); // Wait for end of A/D

return ((i>>6) & 0x3FF);
}

void main(void)
{
init_adc0();
resultc_read(2); //ch_no 7:6;4:1
}

one last thing, in the main() i'm just using the 'result' to get the value here because i do not know what else i can do with it. if i am to load my code on to the board what do you suggest i do with the ADC data? i'm just trying to learn so anything you could tell me would be helpful.

Thanks for reading.
--- In l..., "lucky_suhas" wrote:
>
> Hi,
> i have just started learning to use the LPC2148. the code is for using one of the channels in ADC0.i tried compiling my code and there seems to be something wrong. i'm getting an
>
> "Error: C9932E"
>
> in "keil".
>

See:

http://www.keil.com/support/docs/3420.htm

Regards,
Chris Burrows

CFB Software
Astrobe v3.4: LPC2000 Oberon-07 Development System
http://www.astrobe.com

what error u r getting exactly

On Sun, Aug 28, 2011 at 3:37 AM, lucky_suhas wrote:

> **
> Hi,
> i have just started learning to use the LPC2148. the code is for using one
> of the channels in ADC0.i tried compiling my code and there seems to be
> something wrong. i'm getting an
>
> "Error: C9932E"
>
> in "keil".
>
> the purpose of the code is to see how adc works on this micro-controller.
> could anyone tell me what i am doing wrong?
> my code is as below:
>
> #include void init_adc0(void)
> {
> PINSEL0 = (PINSEL0 & ~(3 << 8)) | (3 << 8)& ~(3 << 10)) | (3 << 10);
> PINSEL1=(PINSEL1 & ~(3 << 18)) | (1 << 18)& ~(3 << 24)) | (1 << 24)& ~(3 <<
> 26)) | (1 << 26)& ~(3 << 28)) | (1 << 28);
> }
>
> unsigned adc_read(unsigned char ch_no)
> {
> AD0CR=0x00200000 & (1< >
> do
> {
> i = AD0GDR; // Read A/D Data Register
> } while ((i & 0x80000000) == 0); // Wait for end of A/D
>
> return ((i>>6) & 0x3FF);
> }
>
> void main(void)
> {
> init_adc0();
> resultc_read(2); //ch_no 7:6;4:1
> }
>
> one last thing, in the main() i'm just using the 'result' to get the value
> here because i do not know what else i can do with it. if i am to load my
> code on to the board what do you suggest i do with the ADC data? i'm just
> trying to learn so anything you could tell me would be helpful.
>
> Thanks for reading.
>
>
>

--
Regards,
Suresh
Check your brackets in init_adc0(), you have more closing than opening brackets per line.

--- In l..., "lucky_suhas" wrote:
>
> Hi,
> i have just started learning to use the LPC2148. the code is for using one of the channels in ADC0.i tried compiling my code and there seems to be something wrong. i'm getting an
>
> "Error: C9932E"
>
> in "keil".
>
> the purpose of the code is to see how adc works on this micro-controller.
> could anyone tell me what i am doing wrong?
> my code is as below:
>
> #include void init_adc0(void)
> {
> PINSEL0 = (PINSEL0 & ~(3 << 8)) | (3 << 8)& ~(3 << 10)) | (3 << 10);
> PINSEL1=(PINSEL1 & ~(3 << 18)) | (1 << 18)& ~(3 << 24)) | (1 << 24)& ~(3 << 26)) | (1 << 26)& ~(3 << 28)) | (1 << 28);
> }
>
> unsigned adc_read(unsigned char ch_no)
> {
> AD0CR=0x00200000 & (1< >
> do
> {
> i = AD0GDR; // Read A/D Data Register
> } while ((i & 0x80000000) == 0); // Wait for end of A/D
>
> return ((i>>6) & 0x3FF);
> }
>
> void main(void)
> {
> init_adc0();
> resultc_read(2); //ch_no 7:6;4:1
> }
> one last thing, in the main() i'm just using the 'result' to get the value here because i do not know what else i can do with it. if i am to load my code on to the board what do you suggest i do with the ADC data? i'm just trying to learn so anything you could tell me would be helpful.
>
> Thanks for reading.
>

On 28-8-2011 12:07, lucky_suhas wrote:
> AD0CR=0x00200000 & (1<
This looks weird. Didn't you mean to use | instead of & ?

Also, I think you should set CLKDIV in AD0CR too, otherwise
you might be configuring it to run way too fast.

Kind regards,
Bertrik
i did not know about the endless loop. thank you!
i found out about the error. it's a compiler error so i have to just download the latest .exe file for keil.

thanks again for the tip!
--- In l..., "Alexan_e" wrote:
>
> There should be an explanation after the Error: C9932E, doesn't is say anything else?
> You should always use an endless loop, the execution shouldn't be allowed to exit the mail loop, the minimum you should use is a while(1); at the last line of the main function.
> You can assign the ADC result to 10 output pins if you want to use it somehow.
>
> Alex
>
> ----- Original Message -----
> From: lucky_suhas
> To: l...
> Sent: Sunday, August 28, 2011 1:07 AM
> Subject: [lpc2000] errors in my ADC code for LPC2148 (beginner)
>
> Hi,
> i have just started learning to use the LPC2148. the code is for using one of the channels in ADC0.i tried compiling my code and there seems to be something wrong. i'm getting an
>
> "Error: C9932E"
>
> in "keil".
>
> the purpose of the code is to see how adc works on this micro-controller.
> could anyone tell me what i am doing wrong?
> my code is as below:
>
> #include void init_adc0(void)
> {
> PINSEL0 = (PINSEL0 & ~(3 << 8)) | (3 << 8)& ~(3 << 10)) | (3 << 10);
> PINSEL1=(PINSEL1 & ~(3 << 18)) | (1 << 18)& ~(3 << 24)) | (1 << 24)& ~(3 << 26)) | (1 << 26)& ~(3 << 28)) | (1 << 28);
> }
>
> unsigned adc_read(unsigned char ch_no)
> {
> AD0CR=0x00200000 & (1< >
> do
> {
> i = AD0GDR; // Read A/D Data Register
> } while ((i & 0x80000000) == 0); // Wait for end of A/D
>
> return ((i>>6) & 0x3FF);
> }
>
> void main(void)
> {
> init_adc0();
> resultc_read(2); //ch_no 7:6;4:1
> }
>
> one last thing, in the main() i'm just using the 'result' to get the value here because i do not know what else i can do with it. if i am to load my code on to the board what do you suggest i do with the ADC data? i'm just trying to learn so anything you could tell me would be helpful.
>
> Thanks for reading.
>

thanks for the link!
--- In l..., "cfbsoftware1" wrote:
>
> --- In l..., "lucky_suhas" wrote:
> >
> > Hi,
> > i have just started learning to use the LPC2148. the code is for using one of the channels in ADC0.i tried compiling my code and there seems to be something wrong. i'm getting an
> >
> > "Error: C9932E"
> >
> > in "keil".
> > See:
>
> http://www.keil.com/support/docs/3420.htm
>
> Regards,
> Chris Burrows
>
> CFB Software
> Astrobe v3.4: LPC2000 Oberon-07 Development System
> http://www.astrobe.com
>

it was just a compiler license error. thanks for replying.

--- In l..., suresh chowdary ambati wrote:
>
> what error u r getting exactly
>
> On Sun, Aug 28, 2011 at 3:37 AM, lucky_suhas wrote:
>
> > **
> >
> >
> > Hi,
> > i have just started learning to use the LPC2148. the code is for using one
> > of the channels in ADC0.i tried compiling my code and there seems to be
> > something wrong. i'm getting an
> >
> > "Error: C9932E"
> >
> > in "keil".
> >
> > the purpose of the code is to see how adc works on this micro-controller.
> > could anyone tell me what i am doing wrong?
> > my code is as below:
> >
> > #include
> >
> > void init_adc0(void)
> > {
> > PINSEL0 = (PINSEL0 & ~(3 << 8)) | (3 << 8)& ~(3 << 10)) | (3 << 10);
> > PINSEL1=(PINSEL1 & ~(3 << 18)) | (1 << 18)& ~(3 << 24)) | (1 << 24)& ~(3 <<
> > 26)) | (1 << 26)& ~(3 << 28)) | (1 << 28);
> > }
> >
> > unsigned adc_read(unsigned char ch_no)
> > {
> > AD0CR=0x00200000 & (1< > >
> > do
> > {
> > i = AD0GDR; // Read A/D Data Register
> > } while ((i & 0x80000000) == 0); // Wait for end of A/D
> >
> > return ((i>>6) & 0x3FF);
> > }
> >
> > void main(void)
> > {
> > init_adc0();
> > resultc_read(2); //ch_no 7:6;4:1
> > }
> >
> > one last thing, in the main() i'm just using the 'result' to get the value
> > here because i do not know what else i can do with it. if i am to load my
> > code on to the board what do you suggest i do with the ADC data? i'm just
> > trying to learn so anything you could tell me would be helpful.
> >
> > Thanks for reading.
> >
> >
> > --
> Regards,
> Suresh
>

i'm sorry i for got to correct that one part before posting it. is everything else proper? any suggestions or tips you might have will be quite helpful.

--- In l..., "Matthias" wrote:
>
> Check your brackets in init_adc0(), you have more closing than opening brackets per line.
>
> --- In l..., "lucky_suhas" wrote:
> >
> > Hi,
> > i have just started learning to use the LPC2148. the code is for using one of the channels in ADC0.i tried compiling my code and there seems to be something wrong. i'm getting an
> >
> > "Error: C9932E"
> >
> > in "keil".
> >
> > the purpose of the code is to see how adc works on this micro-controller.
> > could anyone tell me what i am doing wrong?
> > my code is as below:
> >
> > #include
> >
> > void init_adc0(void)
> > {
> > PINSEL0 = (PINSEL0 & ~(3 << 8)) | (3 << 8)& ~(3 << 10)) | (3 << 10);
> > PINSEL1=(PINSEL1 & ~(3 << 18)) | (1 << 18)& ~(3 << 24)) | (1 << 24)& ~(3 << 26)) | (1 << 26)& ~(3 << 28)) | (1 << 28);
> > }
> >
> > unsigned adc_read(unsigned char ch_no)
> > {
> > AD0CR=0x00200000 & (1< > >
> > do
> > {
> > i = AD0GDR; // Read A/D Data Register
> > } while ((i & 0x80000000) == 0); // Wait for end of A/D
> >
> > return ((i>>6) & 0x3FF);
> > }
> >
> > void main(void)
> > {
> > init_adc0();
> > resultc_read(2); //ch_no 7:6;4:1
> > }
> >
> >
> > one last thing, in the main() i'm just using the 'result' to get the value here because i do not know what else i can do with it. if i am to load my code on to the board what do you suggest i do with the ADC data? i'm just trying to learn so anything you could tell me would be helpful.
> >
> > Thanks for reading.
>