EmbeddedRelated.com
Forums

Keil simulator not copying during IAP as expected

Started by Prerak Sheth August 1, 2009
I am using Keil uVision3 v3.31 and am facing a problem in writing to Flash
memory using the IAP (iap_entry). I am getting good reply status (SUCCESS 0), and the memory viewer also indicates that the RAM has been read and
flash written to. However, no actual data gets copied into the flash. All
data gets initialized to 0. Please help to resolve!

Here is the code snippet
#include
#define MYDATALOCATION 0x40004000

#define IAP_LOCATION 0x7ffffff1
unsigned int command[5];
unsigned int result[2];
typedef void (*IAP) (unsigned int [], unsigned int []);
IAP iap_entry;
IAP iap_entry = (IAP) IAP_LOCATION;
void init () {
*((unsigned int *) MYDATALOCATION) = 0x1234;
*((unsigned int *) MYDATALOCATION + 1) = 0x5678;
command[0] = 50;
command[1] = 10;
command[2] = 10;
iap_entry (command, result);
command[0] = 51;
command[1] = 0x18000;
command[2] = MYDATALOCATION;
command[3] = 4096;
command[4] = 12000;
iap_entry (command, result);
}
void main () {
init ();
while (1);
}


An Engineer's Guide to the LPC2100 Series

Did you erase the sectors first?

Sutton
I am using Keil uVision3 v3.31 and am facing a problem in writing to Flash
>memory using the IAP (iap_entry). I am getting good reply status (SUCCESS >0), and the memory viewer also indicates that the RAM has been read and
>flash written to. However, no actual data gets copied into the flash. All
>data gets initialized to 0. Please help to resolve!
>
>Here is the code snippet
>#include
>#define MYDATALOCATION 0x40004000
>
>#define IAP_LOCATION 0x7ffffff1
>unsigned int command[5];
>unsigned int result[2];
>typedef void (*IAP) (unsigned int [], unsigned int []);
>IAP iap_entry;
>IAP iap_entry = (IAP) IAP_LOCATION;
>void init () {
> *((unsigned int *) MYDATALOCATION) = 0x1234;
> *((unsigned int *) MYDATALOCATION + 1) = 0x5678;
> command[0] = 50;
> command[1] = 10;
> command[2] = 10;
> iap_entry (command, result);
> command[0] = 51;
> command[1] = 0x18000;
> command[2] = MYDATALOCATION;
> command[3] = 4096;
> command[4] = 12000;
> iap_entry (command, result);
>}
>void main () {
> init ();
> while (1);
>}
>
>
>
I can do that, however, there is no mention to "erase" the sectors before
writing - only to prepare.
I will try this and get back, thanks for the suggestion
Regards,
Prerak
On Thu, Aug 6, 2009 at 9:51 PM, wrote:

> Did you erase the sectors first?
>
> Sutton
> I am using Keil uVision3 v3.31 and am facing a problem in writing to Flash
> >memory using the IAP (iap_entry). I am getting good reply status (SUCCESS
> > >0), and the memory viewer also indicates that the RAM has been read and
> >flash written to. However, no actual data gets copied into the flash. All
> >data gets initialized to 0. Please help to resolve!
> >
> >Here is the code snippet
> >#include
> >#define MYDATALOCATION 0x40004000
> >
> >#define IAP_LOCATION 0x7ffffff1
> >unsigned int command[5];
> >unsigned int result[2];
> >typedef void (*IAP) (unsigned int [], unsigned int []);
> >IAP iap_entry;
> >IAP iap_entry = (IAP) IAP_LOCATION;
> >void init () {
> > *((unsigned int *) MYDATALOCATION) = 0x1234;
> > *((unsigned int *) MYDATALOCATION + 1) = 0x5678;
> > command[0] = 50;
> > command[1] = 10;
> > command[2] = 10;
> > iap_entry (command, result);
> > command[0] = 51;
> > command[1] = 0x18000;
> > command[2] = MYDATALOCATION;
> > command[3] = 4096;
> > command[4] = 12000;
> > iap_entry (command, result);
> >}
> >void main () {
> > init ();
> > while (1);
> >}
> >
> >
> >
> >
> >
>
>


For most flash, you can only change a bit from a '1' to a '0'. So, you
should erase the sector first to be able to write any meaningful data.
This sets the bytes to 0xFF.

It should tell you in the datasheet.

Sutton

Prerak Sheth wrote:
>
>
> I can do that, however, there is no mention to "erase" the sectors before
> writing - only to prepare.
> I will try this and get back, thanks for the suggestion
> Regards,
> Prerak
>
> On Thu, Aug 6, 2009 at 9:51 PM, > > wrote:
>
> >
> >
> > Did you erase the sectors first?
> >
> > Sutton
> >
> >
> > I am using Keil uVision3 v3.31 and am facing a problem in writing to
> Flash
> > >memory using the IAP (iap_entry). I am getting good reply status
> (SUCCESS
> > > > >0), and the memory viewer also indicates that the RAM has been read and
> > >flash written to. However, no actual data gets copied into the
> flash. All
> > >data gets initialized to 0. Please help to resolve!
> > >
> > >Here is the code snippet
> > >#include
> > >#define MYDATALOCATION 0x40004000
> > >
> > >#define IAP_LOCATION 0x7ffffff1
> > >unsigned int command[5];
> > >unsigned int result[2];
> > >typedef void (*IAP) (unsigned int [], unsigned int []);
> > >IAP iap_entry;
> > >IAP iap_entry = (IAP) IAP_LOCATION;
> > >void init () {
> > > *((unsigned int *) MYDATALOCATION) = 0x1234;
> > > *((unsigned int *) MYDATALOCATION + 1) = 0x5678;
> > > command[0] = 50;
> > > command[1] = 10;
> > > command[2] = 10;
> > > iap_entry (command, result);
> > > command[0] = 51;
> > > command[1] = 0x18000;
> > > command[2] = MYDATALOCATION;
> > > command[3] = 4096;
> > > command[4] = 12000;
> > > iap_entry (command, result);
> > >}
> > >void main () {
> > > init ();
> > > while (1);
> > >}
> > >
> > >
> > >
> > >
> > >
> >
> >

--
Sutton Mehaffey
Lookout Portable Security
4040 Royal Dr. #100
Kennesaw, GA 30144
800-207-6269, 770-514-7999, 770-514-1285 FAX
s...@lookoutportablesecurity.com

You are spot on Sutton.
May be my mistake that I did not notice that in the instructions, but after
doing an "erase" it works just fine.
Thanks a lot and appreciate your help
Regards,
Prerak

On Fri, Aug 7, 2009 at 8:09 AM, Sutton Mehaffey <
s...@lookoutportablesecurity.com> wrote:

> For most flash, you can only change a bit from a '1' to a '0'. So, you
> should erase the sector first to be able to write any meaningful data.
> This sets the bytes to 0xFF.
>
> It should tell you in the datasheet.
>
> Sutton
> Prerak Sheth wrote:
> >
> >
> > I can do that, however, there is no mention to "erase" the sectors before
> > writing - only to prepare.
> > I will try this and get back, thanks for the suggestion
> > Regards,
> > Prerak
> >
> > On Thu, Aug 6, 2009 at 9:51 PM,
> > >> wrote:
> >
> > >
> > >
> > > Did you erase the sectors first?
> > >
> > > Sutton
> > >
> > >
> > > I am using Keil uVision3 v3.31 and am facing a problem in writing to
> > Flash
> > > >memory using the IAP (iap_entry). I am getting good reply status
> > (SUCCESS
> > > > > > >0), and the memory viewer also indicates that the RAM has been read
> and
> > > >flash written to. However, no actual data gets copied into the
> > flash. All
> > > >data gets initialized to 0. Please help to resolve!
> > > >
> > > >Here is the code snippet
> > > >#include
> > > >#define MYDATALOCATION 0x40004000
> > > >
> > > >#define IAP_LOCATION 0x7ffffff1
> > > >unsigned int command[5];
> > > >unsigned int result[2];
> > > >typedef void (*IAP) (unsigned int [], unsigned int []);
> > > >IAP iap_entry;
> > > >IAP iap_entry = (IAP) IAP_LOCATION;
> > > >void init () {
> > > > *((unsigned int *) MYDATALOCATION) = 0x1234;
> > > > *((unsigned int *) MYDATALOCATION + 1) = 0x5678;
> > > > command[0] = 50;
> > > > command[1] = 10;
> > > > command[2] = 10;
> > > > iap_entry (command, result);
> > > > command[0] = 51;
> > > > command[1] = 0x18000;
> > > > command[2] = MYDATALOCATION;
> > > > command[3] = 4096;
> > > > command[4] = 12000;
> > > > iap_entry (command, result);
> > > >}
> > > >void main () {
> > > > init ();
> > > > while (1);
> > > >}
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
> >
> > --
> Sutton Mehaffey
> Lookout Portable Security
> 4040 Royal Dr. #100
> Kennesaw, GA 30144
> 800-207-6269, 770-514-7999, 770-514-1285 FAX
> s...@lookoutportablesecurity.com
>