EmbeddedRelated.com
Forums

errors in my ADC code for LPC2148 (beginner)

Started by lucky_suhas August 27, 2011
you are right. i failed to notice that. thanks for pointing it out.
about that CLKDIV bits, how does it divide the frequency? does the PCLK get divided by the decimal equivalent of the bits 15:8 of AD0CR?
--- In l..., Bertrik Sikken wrote:
>
> 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
>

An Engineer's Guide to the LPC2100 Series

The periphepal clock (Pclock) is divided with the CLKDIV value +1 , CLKDIV are bits 15:8 as you said

try ARMwizard, it can make the calculations and initialization code for you
http://alexan.edaboard.eu

Alex

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

you are right. i failed to notice that. thanks for pointing it out.
about that CLKDIV bits, how does it divide the frequency? does the PCLK get divided by the decimal equivalent of the bits 15:8 of AD0CR?
--- In l..., Bertrik Sikken wrote:
>
> 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
>
>>>
>>>
>>> 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.
>>>

--
Well, you can send the ADC data to serial port. If you have used ISP,
then your serial port is already connected to PC. Simply configure
serial port and send two byte ( for 10 bit data).

Best Regards,
Mukund Deshmukh
Beta Computronics Pvt Ltd
10/1, IT Park, Parsodi
Nagpur, India
Meet us at Booth No 1.1D09,
CHINAPLAS 2011- GUANGZHOU-CHINA

getting this error when i try to compile the file

adc.axf: Error: L6221E: Execution region ER_RO with Execution range [0x00000000,0x000002bc) overlaps with Execution region ER_ZI with Execution range [0x00000000,0x00000060).

--- In l..., "Alexan_e" wrote:
>
> The periphepal clock (Pclock) is divided with the CLKDIV value +1 , CLKDIV are bits 15:8 as you said
>
> try ARMwizard, it can make the calculations and initialization code for you
> http://alexan.edaboard.eu
>
> Alex
>
> ----- Original Message -----
> From: lucky_suhas
> To: l...
> Sent: Sunday, August 28, 2011 4:44 PM
> Subject: [lpc2000] Re: errors in my ADC code for LPC2148 (beginner)
>
>
> you are right. i failed to notice that. thanks for pointing it out.
> about that CLKDIV bits, how does it divide the frequency? does the PCLK get divided by the decimal equivalent of the bits 15:8 of AD0CR?
> --- In l..., Bertrik Sikken wrote:
> >
> > 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 suppose the error you're getting is documented in the documentation of
your toolchain. What is your question exactly?

Kind regards,
Bertrik

> getting this error when i try to compile the file
>
> adc.axf: Error: L6221E: Execution region ER_RO with Execution range
> [0x00000000,0x000002bc) overlaps with Execution region ER_ZI with
> Execution range [0x00000000,0x00000060).
>
> --- In l..., "Alexan_e" wrote:
>>
>> The periphepal clock (Pclock) is divided with the CLKDIV value +1 ,
>> CLKDIV are bits 15:8 as you said
>>
>> try ARMwizard, it can make the calculations and initialization code for
>> you
>> http://alexan.edaboard.eu
>>
>> Alex
>>
>> ----- Original Message -----
>> From: lucky_suhas
>> To: l...
>> Sent: Sunday, August 28, 2011 4:44 PM
>> Subject: [lpc2000] Re: errors in my ADC code for LPC2148 (beginner)
>> you are right. i failed to notice that. thanks for pointing it out.
>> about that CLKDIV bits, how does it divide the frequency? does the
>> PCLK get divided by the decimal equivalent of the bits 15:8 of AD0CR?
>> --- In l..., Bertrik Sikken wrote:
>> >
>> > 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.

i tried 'build target' for compiling my code, it says there's a linking error and the two regions ER_RO and ER_ZI are overlapping. i wanted to know how i can fix this? i found something about scatter fields when i searched for the error code L6221E. i did not understand how to make use of that info.

the link i found is here:

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0496c/BABHAIBE.html

thanks!
--- In l..., "Bertrik Sikken" wrote:
>
> I suppose the error you're getting is documented in the documentation of
> your toolchain. What is your question exactly?
>
> Kind regards,
> Bertrik
>
> > getting this error when i try to compile the file
> >
> > adc.axf: Error: L6221E: Execution region ER_RO with Execution range
> > [0x00000000,0x000002bc) overlaps with Execution region ER_ZI with
> > Execution range [0x00000000,0x00000060).
> >
> > --- In l..., "Alexan_e" wrote:
> >>
> >> The periphepal clock (Pclock) is divided with the CLKDIV value +1 ,
> >> CLKDIV are bits 15:8 as you said
> >>
> >> try ARMwizard, it can make the calculations and initialization code for
> >> you
> >> http://alexan.edaboard.eu
> >>
> >> Alex
> >>
> >> ----- Original Message -----
> >> From: lucky_suhas
> >> To: l...
> >> Sent: Sunday, August 28, 2011 4:44 PM
> >> Subject: [lpc2000] Re: errors in my ADC code for LPC2148 (beginner)
> >>
> >>
> >>
> >>
> >> you are right. i failed to notice that. thanks for pointing it out.
> >> about that CLKDIV bits, how does it divide the frequency? does the
> >> PCLK get divided by the decimal equivalent of the bits 15:8 of AD0CR?
> >> --- In l..., Bertrik Sikken wrote:
> >> >
> >> > 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.
>

--- In l..., "lucky_suhas" wrote:
> i tried 'build target' for compiling my code, it says there's a linking error and the two regions ER_RO and ER_ZI are overlapping. i wanted to know how i can fix this? i found something about scatter fields when i searched for the error code L6221E. i did not understand how to make use of that info.
>
> the link i found is here:
>
> http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0496c/BABHAIBE.html
>
> thanks!

If you follow this link from the page you referenced, you will see how to modify the scatter file using ImageLimit() to eliminate the overlap:

http://infocenter.arm.com/help/topic/com.arm.doc.dui0493c/BABFJEAI.html

I have only used the free version of Keil uVision4 so I don't have much experience with the toolchain. But one thing I know for certain: I didn't have to get involved with scatter files or the linker. I just created a project, added a couple of files and everything worked just fine.

I used the Keil Startup.s and retarget.c but the rest of the files were mine. All I did was create a new project and select the NXP LPC2148. The editor asked about adding Startup.s and I'm not sure how I added retarget.c. It is required as it provides linkage between Keil's fputc() and my sendchar() function. fputc() is required by printf().

Richard

thanks. i found a work around for it. i had to save my code on the existing example projects.. I did not understand how to use the information on that link. I do not even know what scatter files are. and my programming skills go only so far.
--- In l..., "rtstofer" wrote:
>
> --- In l..., "lucky_suhas" wrote:
> >
> >
> > i tried 'build target' for compiling my code, it says there's a linking error and the two regions ER_RO and ER_ZI are overlapping. i wanted to know how i can fix this? i found something about scatter fields when i searched for the error code L6221E. i did not understand how to make use of that info.
> >
> > the link i found is here:
> >
> > http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0496c/BABHAIBE.html
> >
> > thanks!
>
> If you follow this link from the page you referenced, you will see how to modify the scatter file using ImageLimit() to eliminate the overlap:
>
> http://infocenter.arm.com/help/topic/com.arm.doc.dui0493c/BABFJEAI.html
>
> I have only used the free version of Keil uVision4 so I don't have much experience with the toolchain. But one thing I know for certain: I didn't have to get involved with scatter files or the linker. I just created a project, added a couple of files and everything worked just fine.
>
> I used the Keil Startup.s and retarget.c but the rest of the files were mine. All I did was create a new project and select the NXP LPC2148. The editor asked about adding Startup.s and I'm not sure how I added retarget.c. It is required as it provides linkage between Keil's fputc() and my sendchar() function. fputc() is required by printf().
>
> Richard
>

--- In l..., "lucky_suhas" wrote:
> thanks. i found a work around for it. i had to save my code on the existing example projects.. I did not understand how to use the information on that link. I do not even know what scatter files are. and my programming skills go only so far.

Here is a scatter file (.scf) for a typical LPC2148 project:

; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************

LR_IROM1 0x00000000 0x00080000 { ; load region size_region
ER_IROM1 0x00000000 0x00080000 { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
}
RW_IRAM1 0x40000000 0x00008000 { ; RW data
.ANY (+RW +ZI)
}
}

I wouldn't expect any overlap problems with this file because the ZI sections are placed in RAM (where they belong).

This file should have been created by uVision when you set up a project and selected NXP LPC2148 for the target. You really shouldn't have to deal with it.

Richard