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
IAP writes corrupted data to flash
Started by ●March 9, 2014
Reply by ●March 9, 20142014-03-09
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
> 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
Reply by ●March 9, 20142014-03-09
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
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
Reply by ●March 9, 20142014-03-09
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
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
Reply by ●March 22, 20142014-03-22
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]
>
>
> 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
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]
Reply by ●March 22, 20142014-03-22
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
>
>
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
>
>