Posted by Naresh Panchal March 22, 2014
Before writing you should first erase sector
On Mar 10, 2014 12:56 AM, wrote:

> Hello,
>
> I am trying to program the flash of a LPC2387 via IAP. I use the code
> provided in the LPC2300 user manual.
> When I try to write a simple test pattern (0x00, 0x11, 0x00, 0x11...),
> after reading again I get corrupted data like 0x00, 0x01, 0x00, 0x10. So
> something is written, and you can recall the pattern, but the data is
> corrupted.
> Here is my write routine:
> iap_command[0] = IAP_PREPARE;
> iap_command[1] = sector;
> iap_command[2] = sector;
> iap_entry(iap_command, iap_result); // Prepare the
> sector(s).
>
> iap_command[0] = IAP_COPY; // Copy RAM to flash.
> iap_command[1] = writeptr; // Destination in flash.
> iap_command[2] = codebuffer; // Source in RAM.
> iap_command[3] = ctr; // Size in bytes.
> iap_command[4] = Fcclk / 1000UL; // System clock in kHz.
> iap_entry(iap_command, iap_result); // Copy RAM to flash.
>
> The LPC2387 runs at 50MHz core clock. iap_result[0] is zero after both
> calls of iap_entry. Any suggestion why the routines exit without any error
> but the written data is corrupted?
>
> Regards,
> Laurenz
>
>

An Engineer's Guide to the LPC2100 Series

Posted by "M. Manca" March 22, 2014
Il 09/03/2014 23:28, l...@gmx.de ha scritto:
>
>
> Hello Timo,
> yes, I forgot to erase the sectors before writing to them. Works like
> a charm now.
Also remember to disable the interrupts or to execute the code from RAM.
>
> Thank you for your input,
> Laurenz
> ---In l..., wrote :
>
> On 09.03.2014 21:26, laurenz.kamp@... wrote:
>
> > I am trying to program the flash of a LPC2387 via IAP. I use the
> code
> > provided in the LPC2300 user manual.
> > When I try to write a simple test pattern (0x00, 0x11, 0x00,
> 0x11...),
> > after reading again I get corrupted data like 0x00, 0x01, 0x00,
> 0x10. So
> > something is written, and you can recall the pattern, but the
> data is
> > corrupted.
>
> Are you sure the memory area was erased? Have you checked for that
> before writing?
>
> --
>
> Timo
>
>
>
>
> Questa e-mail è priva di virus e malware perché è attiva la protezione
> avast! Antivirus .

logo
*

Massimo Manca*/, Micron Engineering/
via della Ferriera, 48 33170 Pordenone PN ITALIA
Tel: 39 0434 1856131| Mobile: 39 349 4504979
www.micronengineering.it

Twitter

LinkedIn

SlideShare

Contact me: Skype micron.engineering
Designed with WiseStamp -
Get
yours

---
Questa e-mail è priva di virus e malware perché è attiva la protezione avast! Antivirus.
http://www.avast.com
[Non-text portions of this message have been removed]



Posted by laur...@gmx.de March 9, 2014
Hello Timo,

yes, I forgot to erase the sectors before writing to them. Works like a charm now.

Thank you for your input,
Laurenz

---In l..., wrote :

On 09.03.2014 21:26, laurenz.kamp@... mailto:laurenz.kamp@... wrote:
> I am trying to program the flash of a LPC2387 via IAP. I use the code
> provided in the LPC2300 user manual.
> When I try to write a simple test pattern (0x00, 0x11, 0x00, 0x11...),
> after reading again I get corrupted data like 0x00, 0x01, 0x00, 0x10. So
> something is written, and you can recall the pattern, but the data is
> corrupted.

Are you sure the memory area was erased? Have you checked for that
before writing?

--

Timo
Posted by cfbs...@internode.on.net March 9, 2014
Make sure your program is not using the 'RAM that is used by the ISP command handler'. See your LPC User Manual for details. You might also have to disable interrupts.
Other than that, double-check that the address being assigned to iap_command[2] in the IAP copy command is what you think it should be.
Regards,
Chris Burrows
CFB Software
http://www.astrobe.com http://www.astrobe.com
Posted by Timo March 9, 2014
On 09.03.2014 21:26, l...@gmx.de wrote:
> I am trying to program the flash of a LPC2387 via IAP. I use the code
> provided in the LPC2300 user manual.
> When I try to write a simple test pattern (0x00, 0x11, 0x00, 0x11...),
> after reading again I get corrupted data like 0x00, 0x01, 0x00, 0x10. So
> something is written, and you can recall the pattern, but the data is
> corrupted.

Are you sure the memory area was erased? Have you checked for that
before writing?

--

Timo



Posted by laur...@gmx.de March 9, 2014
Hello,

I am trying to program the flash of a LPC2387 via IAP. I use the code provided in the LPC2300 user manual.
When I try to write a simple test pattern (0x00, 0x11, 0x00, 0x11...), after reading again I get corrupted data like 0x00, 0x01, 0x00, 0x10. So something is written, and you can recall the pattern, but the data is corrupted.
Here is my write routine:
iap_command[0] = IAP_PREPARE;
iap_command[1] = sector;
iap_command[2] = sector;
iap_entry(iap_command, iap_result); // Prepare the sector(s).

iap_command[0] = IAP_COPY; // Copy RAM to flash.
iap_command[1] = writeptr; // Destination in flash.
iap_command[2] = codebuffer; // Source in RAM.
iap_command[3] = ctr; // Size in bytes.
iap_command[4] = Fcclk / 1000UL; // System clock in kHz.
iap_entry(iap_command, iap_result); // Copy RAM to flash.

The LPC2387 runs at 50MHz core clock. iap_result[0] is zero after both calls of iap_entry. Any suggestion why the routines exit without any error but the written data is corrupted?

Regards,
Laurenz