Read EEPROM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Read EEPROM

1,716 Views
ianbenton
Senior Contributor I

As the EEPROM is memory mapped at 0x03200000, is it necessary to use the IAP commands to read it? Or can it simply be accessed the same as the flash or SRAM?

e.g.

LDR R3,=0x03200000

LDR R0,[R3]

Labels (1)
0 Kudos
9 Replies

1,381 Views
ianbenton
Senior Contributor I

And this morning it works - and I struggled to see what I had done differently. I moved the parameter block so that it was next to the target RAM so I could put them both on the same screen-shot for you. Was it something to do with memory alignment?

No - I put R1 (result pointer) twenty bytes higher than R0 (data pointer), and now it works. 

So the statement in the manual "The user can reuse the command table for result by passing the same pointer in registers R0 and R1" is false. If I do that, the IAP call fails. R1 and R0 must be different.

Also, the command sequence

LDR R3,=0x03200000

LDR R0,[R3]

really DOES read correctly from the EEPROM.

I can also confirm that the RAM address must be an absolute address, and the EEPROM address must be a relative address (relative to the start of the EEPROM block). Otherwise status code 0x0E is returned, a status code which is not listed in Table 511.

I think perhaps you need to speak to the people who wrote the manual!

0 Kudos

1,381 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Ian Benton ,

Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
Please using the IAP command.
Hope this is clear.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,381 Views
ianbenton
Senior Contributor I

I tried the IAP command for but got "invalid command". 

My memory block contained 62 (decimal),0x03200000,0x02000004,4,0 and R0 and R1 contained the address of the memory block.

 After the branch to 0x03000205, 61 was overwritten by 1 (invalid command).

Any clues as to what is wrong? Should the EEPROM address be the absolute address, or the offset from the beginning of EEPROM?

0 Kudos

1,381 Views
ianbenton
Senior Contributor I

A few other notes:

If I write BL 0x03000205 (or even BL 0x03000204) it crashes with a hard fault.

If I write LDR R3,=0x03000205

BLX R3

Then it appears to execute some API command but always returns with an "invalid command" error. i.e the address that contained the command number is overwritten by 1. This happens for every command, even a "read device ID"

It says in the manual that it requires the top 32 bytes of RAM. On an LPC1517 does that mean the top 32 bytes of RAM0 (where the stack normally goes) or the top 32 bytes of RAM2?

The manual seems a bit unclear as to how to pass the parameters saying on page 572 that 4 parameters or fewer can be passed via R0-R3, and only when there are more than 4 is the block of RAM required. I assume that the API always uses the RAM block, or is that where the problem is?

0 Kudos

1,381 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Ian Benton,

Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
1) On an LPC1517 does that mean the top 32 bytes of RAM0 (where the stack normally goes) or the top 32 bytes of RAM2?
-- The top 32 bytes of RAM2.
I'd highly recommend you to refer the eeprom demo in LPCOpen library, this demo illustrates how to use the IAP commands to read and write a small test string from and to the EEPROM.

Have a great day,
TIC

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,381 Views
ianbenton
Senior Contributor I

Thank you for your assistance.

I have examined the LPCOpen code, and found that my code does precisely the same as the eeprom.c example, except that I wrote it in 14 lines of code, and the compiler compiled it to 49 lines. It does confirm that the data is passed in a block of memory, not in registers R0-R3, but it does not specify whether the EEPROM address is absolute, or relative to the start of the EEPROM block.

The only difference in the example code is that the EEPROM bit in PRESETCTRL0 is asserted and negated beforehand. I tried that and it makes no difference.

It is interesting that WHATEVER command is placed in <command code> the IAP subroutine returns 167 cycles later with an "invalid command" result. A "read eprom" command and a "read uid" command both return 167 cycles later with "invalid command".

The EEPROM bit is set in both PDRUNCFG and SYSAHBCLKCTRL (although the LPCOpen routine appears no to check it in PDRUNCFG)

0 Kudos

1,381 Views
ianbenton
Senior Contributor I

I tried the LPCopen project, but all I got was "flash driver failed to initialise".

0 Kudos

1,381 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Ian Benton,

Whether you can share a screen about the issue.

Have a great day,
TIC

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,381 Views
ianbenton
Senior Contributor I

and how can I delete "assumed answered" from the header?

0 Kudos