EmbDev.net

Forum: ARM programming with GCC/GNU tools use flash on lpc2148


von Guest (Guest)


Rate this post
useful
not useful
Hi,
I use eclipse and the GNU ARM Compiler suit for Windows
I must store some char in flash on Phillips lpc2148.
I have defined the varriable test:

unsigned char test _attribute_ ((section (".mySection"))) = 48;

and the compiler call is:

arm-elf-ld -v -S -M -section-start=.mySection=0x00010000

the problem is now, the lpc2148 restart if I would write to "test"
how I could write to the varriable?!?

thx
Marco

von Martin T. (mthomas) (Moderator)


Rate this post
useful
not useful
Guest wrote:
> Hi,
> I use eclipse and the GNU ARM Compiler suit for Windows
> I must store some char in flash on Phillips lpc2148.
> I have defined the varriable test:
>
> unsigned char test _attribute_ ((section (".mySection"))) = 48;
>
> and the compiler call is:
>
> arm-elf-ld -v -S -M -section-start=.mySection=0x00010000
>
> the problem is now, the lpc2148 restart if I would write to "test"
> how I could write to the varriable?!?

You can not simply modify the flash-content like this. Read the section
about IAP in the LPC214x manual.

Martin Thomas

von Guest (Guest)


Rate this post
useful
not useful
Martin Thomas wrote:
>
> You can not simply modify the flash-content like this. Read the section
> about IAP in the LPC214x manual.
>
> Martin Thomas

I had read this section. If I want to prepare a flash section the µC
restarts.
my code is:

// IAP start location on flash
#define IAP_LOCATION  0x7FFFFFF0
// contains parameters for IAP command
unsigned int iap_command[5];
// contains results, returned by "Blankcheck sector(s)"
unsigned int iap_result[2];
// typedefinition for IAP entry function
typedef void (*IAP) (unsigned int[],unsigned int[]);
IAP IAP_Entry;

/*
 * Write data to flash
 */
void IAP_Write (void)
{
  IAP_Entry = (IAP) IAP_LOCATION;
  // IAP write command for prepare sectors for write
  // set command code
  iap_command[0] = 50;
  // set start sector number
  iap_command[1] = 0x0A;
  // set stop sector number
  iap_command[2] = 0x0A;
  // prepare sectors for write
  IAP_Entry(iap_command,iap_result);
}

Do you see whats wrong?

thx
Marco

von Martin T. (mthomas) (Moderator)


Rate this post
useful
not useful
Guest wrote:

> #define IAP_LOCATION  0x7FFFFFF0
Where did you get this from? AFAIK the IAP-entry function is thumb-code
so this should be an odd number.

>   IAP_Entry(iap_command,iap_result);
How does the Compiler translate this? Can you show the assembler-code
for this? Is IAR_Write compiled for thumb or ARM-mode?


Martin Thomas

von Guest (Guest)


Rate this post
useful
not useful
Thx, I misread the IAP_LOCATION. With the new adress 0x7FFFFFF1 the
Prepare
command works fine.
New problemm is, if I will write to flash the source adress is not on a
correct boundary.

void IAP_Write (void)
{
  // Copy RAM to Flash
  // setting function pointer
  IAP_Entry = (IAP) IAP_LOCATION;
  // set command code
  iap_command[0] = 51;
  // destination flash where data byte to be written
  iap_command[1] = (unsigned long)0x00018000;
  // source RAM address where data bytes are to be read
  iap_command[2] = (unsigned short)&contrast_lokal;
  // number of bytes to be written
  iap_command[3] = 256;
  // set system clock frequency, unit kHz
  iap_command[4] = 60000;
  // prepare sectors for write
  IAP_Entry(iap_command,iap_result);
}

I inexperienced about thumb and arm mode because the arm porzessor is
new for me.

von Guest (Guest)


Rate this post
useful
not useful
Sry I have found the failure.
The source wasn`t word.

thx for help

von Radhika C. (radhikac)


Rate this post
useful
not useful
Guest wrote:
> Thx, I misread the IAP_LOCATION. With the new adress 0x7FFFFFF1 the
> Prepare
> command works fine.
> New problemm is, if I will write to flash the source adress is not on a
> correct boundary.
>
> void IAP_Write (void)
> {
>   // Copy RAM to Flash
>   // setting function pointer
>   IAP_Entry = (IAP) IAP_LOCATION;
>   // set command code
>   iap_command[0] = 51;
>   // destination flash where data byte to be written
>   iap_command[1] = (unsigned long)0x00018000;
>   // source RAM address where data bytes are to be read
>   iap_command[2] = (unsigned short)&contrast_lokal;
>   // number of bytes to be written
>   iap_command[3] = 256;
>   // set system clock frequency, unit kHz
>   iap_command[4] = 60000;
>   // prepare sectors for write
>   IAP_Entry(iap_command,iap_result);
> }
>
> I inexperienced about thumb and arm mode because the arm porzessor is
> new for me.

hi,
i am using LPC-2148 and want to write some coefficients in Flash i have
tried to use IAP code as given in the manual, but it is not working. it
seems you have faced same problem few days back. can you please guide me
how to use this IAP functions for FLash read or Write and how to select
Thumb mode

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.