EmbeddedRelated.com
Forums

EEPROM Emulation

Started by jpss1277 March 21, 2010
I am using Olimex LPC-P2148 board and its OCD debugger in my application development . I intend to use unused flash as substitute of any external EEPROM . As my application demands maximum five write operation during whole lifetime of application . This data will be read only 99% of time . Using flash will save chip cost , board space , fault rate and its rectification cost etc . I do not see any technical and commercial negative point in it (Except one time development time for the solution)hence it is very important for me .
In my eclipse gcc compiler provided by olimex i have tried EE_demo sample code from files section of the forum . Somehow it does not work . On debuggig i found that application stops working when it has to execute following code
iap_entry(command_iap,result_iap);
In the file LPC2k_ee.c .
Actually it can traced to reach undefined interrupt handler . I have tested all values are correct and code is not modified . Pls help its urgent and important .

An Engineer's Guide to the LPC2100 Series

Hello,

if it is urgent and important, i always use a link similar to the following one:
http://www.lmgtfy.com/?q=iap_entry

Sometimes (but not often...) it is also useful to read the user manual:
It gives hidden hints in what situations iap_entry can be called,

General hints:
- check if interrupts are enabled by your application.
- check if crystal frequency of hardware and example does match.
- if PLL is allowed to be switched on.
- if certain area in RAM is used by iap_entry.
- if a problem occurs, which was discussed a lot of times here in the mailing list... (e.g. look around 08.03. / 10.03. / 11.03. of this year)

Best regards,

Martin

--- In l..., "capiman26061973" wrote:
> Sometimes (but not often...) it is also useful to read the user manual:
I have gone through manual many times on this topic .

> - check if interrupts are enabled by your application.
interrupts are disabled prior to executing iap_entry

void ee_erase(unsigned int command_ee,unsigned int result_ee[]){
unsigned int command_iap[5];
unsigned int result_iap[3];
unsigned long int enabled_interrupts;

enabled_interrupts = VICIntEnable; //disable all interrupts
VICIntEnClr = enabled_interrupts;

command_iap[0]P; //prepare sectors from EE_SEC_L to EE_SEC_H for erase
command_iap[1]SEC_L;
command_iap[2]SEC_H;
// uart0Puts("Hello EEPROM!!!\n\r");

iap_entry=(IAP) IAP_LOCATION;

> - check if crystal frequency of hardware and example does match.

checked and corrected earlier
> - if PLL is allowed to be switched on.

how to check ?
> - if certain area in RAM is used by iap_entry.

How to check ?

> - if a problem occurs, which was discussed a lot of times here in the mailing list... (e.g. look around 08.03. / 10.03. / 11.03. of this year)

going through

Thanks Martin for quick and relevant reply

Best Regards
Vinay

Hello jpss1277,

Sunday, March 21, 2010, 3:59:08 PM, you wrote:

j> work . On debuggig i found that application stops working when it has to execute following code
j> iap_entry(command_iap,result_iap);
j> In the file LPC2k_ee.c .
j> Actually it can traced to reach undefined interrupt handler . I
j> have tested all values are correct and code is not modified . Pls help its urgent and important .

Check the generated assembly code at that call. It should use BX or BLX to call the
handler since the target is Thumb code. If it's a BL or a PC load, that can
explain the undefined handler.

--
WBR,
Igor mailto:s...@mail.ru

There is always the sample code at www.jcwren.com/arm

Richard

Thanks Igor
You said
> Check the generated assembly code at that call. It should use BX or BLX to call the
> handler since the target is Thumb code. If it's a BL or a PC load, that can
> explain the undefined handler.
Very true following is assembly code generated and it does not include
iap_entry=(IAP) IAP_LOCATION;
0x00000c30 : ldr r2, [pc, #208] ; 0xd08 <$d>
0x00000c34 : mvn r3, #-2147483634 ; 0x8000000e
0x00000c38 : str r3, [r2]

Here is C code which was compiled by eclise GCC compiler

command_iap[0]P; //prepare sectors from EE_SEC_L to EE_SEC_H for erase
command_iap[1]SEC_L;
command_iap[2]SEC_H;
// uart0Puts("Hello EEPROM!!!\n\r");

iap_entry=(IAP) IAP_LOCATION;
iap_entry(command_iap,result_iap);
whats the solution . I believe this is the only problem otherwise sample (EE_demo from files section of the forum ) from which this this code is excellent .
Pls help in fix this
Vinay

Hello jpss1277,

Sunday, March 21, 2010, 6:36:12 PM, you wrote:

j> Thanks Igor
j> You said
>> Check the generated assembly code at that call. It should use BX or BLX to call the
>> handler since the target is Thumb code. If it's a BL or a PC load, that can
>> explain the undefined handler.

j> Very true following is assembly code generated and it does not include
j> iap_entry=(IAP) IAP_LOCATION;
j> 0x00000c30 : ldr r2, [pc, #208] ; 0xd08 <$d>
j> 0x00000c34 : mvn r3, #-2147483634 ; 0x8000000e
j> 0x00000c38 : str r3, [r2]

This is just the first line, that loads iap_entry variable. The value
is correct (~0x8000000e = 7FFFFFF1). What's the second line, with the actual call?

--
WBR,
Igor mailto:s...@mail.ru

> This is just the first line, that loads iap_entry variable. The value
> is correct (~0x8000000e = 7FFFFFF1). What's the second line, with the actual call?
>
> --
> WBR,
> Igor mailto:skochinsky@...
>
Sorry it was copy mistake i copied wrong segment here is next line

iap_entry(command_iap,result_iap);
0x00000c3c : ldr r3, [pc, #196] ; 0xd08 <$d>
0x00000c40 : sub r2, r11, #40 ; 0x28
0x00000c44 : sub r1, r11, #52 ; 0x34
0x00000c48 : ldr r3, [r3]
0x00000c4c : mov r0, r2
0x00000c50 : mov lr, pc
0x00000c54 : mov pc, r3

As you can see above code does not fulfill conditions as you mentioned earlier i.e.
> >> Check the generated assembly code at that call. It should use BX or BLX to call the
> >> handler since the target is Thumb code. If it's a BL or a PC load, that can
> >> explain the undefined handler.
How can we sort it out

With Regards
Vinay

--- In l..., "capiman26061973" wrote:
>
> Hello,
>
> if it is urgent and important, i always use a link similar to the following one:
> http://www.lmgtfy.com/?q=iap_entry
>
> Sometimes (but not often...) it is also useful to read the user manual:
> It gives hidden hints in what situations iap_entry can be called,
>
> General hints:
> - check if interrupts are enabled by your application.
> - check if crystal frequency of hardware and example does match.
> - if PLL is allowed to be switched on.
> - if certain area in RAM is used by iap_entry.
> - if a problem occurs, which was discussed a lot of times here in the mailing list... (e.g. look around 08.03. / 10.03. / 11.03. of this year)
>
> Best regards,
>
> Martin
>
Hi Martin ,
Thanks for reply.
There are two objectives in posting a query in an such forum
1. To achieve solution of technical bottleneck
2. Understand the concept of problem so that very same thing may not obstruct us from development work

Since i am using a well drafted sample code i.e.EE_demo from file section of this forum itself i prefer to stick to find whats wrong there in me , code or compiler to make my concept clear . This does not mean i am not looking at other stuff but my primary concern is debugging of sample code for EEPROM emulation as given in file section of this forum . Your support is requested .

Vinay

jpss1277 wrote:
> iap_entry(command_iap,result_iap);
> 0x00000c3c : ldr r3, [pc, #196] ; 0xd08 <$d>
> 0x00000c40 : sub r2, r11, #40 ; 0x28
> 0x00000c44 : sub r1, r11, #52 ; 0x34
> 0x00000c48 : ldr r3, [r3]
> 0x00000c4c : mov r0, r2
> 0x00000c50 : mov lr, pc
> 0x00000c54 : mov pc, r3
>
> As you can see above code does not fulfill conditions as you mentioned
> earlier i.e.
> > >> Check the generated assembly code at that call. It should use BX
> or BLX to call the
> > >> handler since the target is Thumb code. If it's a BL or a PC load,
> that can
> > >> explain the undefined handler.
>
> How can we sort it out

Did you use -mthumb-interwork?

http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html

--

Timo