EmbDev.net

Forum: ARM programming with GCC/GNU tools Flash Read and Write in LPC-2148


Author: Radhika Chandratreya (radhikac)
Posted on:

Rate this post
0 useful
not useful
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.can
anyone  please guide me how to use this IAP functions for FLash read or
Write and how to select Thumb mode.  I have used code as:

// IAP start location on flash
#define IAP_LOCATION  0x7FFFFFF1
// 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);
}

it executes fine till IAP_Entry function call. after that compiler can
not translate the instructions or something is going wrong and it goes
into unstoppable execution and also contens of memory doesn't changed.I
am new to ARM so can anyone please help me out in this

Author: Martin Thomas (mthomas) (Moderator)
Posted on:

Rate this post
0 useful
not useful
What settings have been used for building (compiler- and
linker-options)? Show the complete output from the build (make).

Author: Radhika Chandratreya (radhikac)
Posted on:
Attached files:

Rate this post
0 useful
not useful
Martin Thomas wrote:
> What settings have been used for building (compiler- and
> linker-options)? Show the complete output from the build (make).

Rebuilding configuration: Flash ReadWriteUsingIAP - Debug
Updating build tree...

2 file(s) deleted.
Updating build tree...
IAP.C
Linking

Total number of errors: 0
Total number of warnings: 0

Author: Jonathan Dumaresq (dumarjo)
Posted on:

Rate this post
0 useful
not useful
Radhika Chandratreya wrote:
> Martin Thomas wrote:
>> What settings have been used for building (compiler- and
>> linker-options)? Show the complete output from the build (make).
>
> Rebuilding configuration: Flash ReadWriteUsingIAP - Debug
> Updating build tree...
>
> 2 file(s) deleted.
> Updating build tree...
> IAP.C
> Linking
>
> Total number of errors: 0
> Total number of warnings: 0

you are using IAR right ?

Jonathan

Author: Radhika Chandratreya (radhikac)
Posted on:

Rate this post
0 useful
not useful
Jonathan Dumaresq wrote:
> Radhika Chandratreya wrote:
>> Martin Thomas wrote:
>>> What settings have been used for building (compiler- and
>>> linker-options)? Show the complete output from the build (make).
>>
>> Rebuilding configuration: Flash ReadWriteUsingIAP - Debug
>> Updating build tree...
>>
>> 2 file(s) deleted.
>> Updating build tree...
>> IAP.C
>> Linking
>>
>> Total number of errors: 0
>> Total number of warnings: 0
>
> you are using IAR right ?
>
> Jonathan

ya i am using IAR DO you have any suggessions regarding this Flash read
or write.
I need it urgently.

Author: Giovanni Di sirio (gdisirio)
Posted on:

Rate this post
0 useful
not useful
Radhika Chandratreya wrote:
> I need it urgently.

I am not sure this is the problem but...

According to the data sheet, the IAP code uses the top 32 bytes in the
RAM and up to 128 bytes of stack space.
Make sure you don't use those top 32 bytes in your code and that there
is enough space in the stack.

Author: Martin Thomas (mthomas) (Moderator)
Posted on:

Rate this post
0 useful
not useful
Also check if the call to the IAP function though the function-pointer
is relay translated to a "bx <reg>" where reg holds 0x7FFFFFF1. This
should be easy to see if you step though the code with the debugger. If
not you may try to compile the source of IAP_write() in thumb-mode
(don't know the IAR switch for this but should be somewhere in a
dialog-box). If it still does not work show the disassembly of
"IAP_write()".

Author: Radhika Chandratreya (radhikac)
Posted on:
Attached files:

Rate this post
0 useful
not useful
Martin Thomas wrote:
> Also check if the call to the IAP function though the function-pointer
> is relay translated to a "bx <reg>" where reg holds 0x7FFFFFF1. This
> should be easy to see if you step though the code with the debugger. If
> not you may try to compile the source of IAP_write() in thumb-mode
> (don't know the IAR switch for this but should be somewhere in a
> dialog-box). If it still does not work show the disassembly of
> "IAP_write()".

with this I am attaching Disassembly for Flash read/write project in run
condition.plz look into it and guide me actually what is going wrong.
thank you very much for ur response.

Author: Martin Thomas (mthomas) (Moderator)
Posted on:

Rate this post
0 useful
not useful
Radhika Chandratreya wrote:
> with this I am attaching Disassembly for Flash read/write project in run
> condition.plz look into it and guide me actually what is going wrong.
> thank you very much for ur response.

It seems that the compiler generated a "glue" function (ARM->thumb) to
call the IAP-function, which is basically correct since the IAP-function
is thumb-code.

Step though the code in "disassembly view" and check what happens after
BX r3 at Label ??rT0x7FFFFFF1. Does it return as expected?

As already mentioned: try to compile the C-source which calls the IAP
function in thumb-mode, this should avoid the glue-function. As far as I
can see the disassembly shows a code generated for ARM-mode.

Anyway you should ask the IAR-support since this is somehow
compiler-specific. If nothing helps, call the IAP function "manually"
with some (inline-)assembler code.

Author: Radhika Chandratreya (radhikac)
Posted on:

Rate this post
0 useful
not useful
Martin Thomas wrote:
> Radhika Chandratreya wrote:
>> with this I am attaching Disassembly for Flash read/write project in run
>> condition.plz look into it and guide me actually what is going wrong.
>> thank you very much for ur response.
>
> It seems that the compiler generated a "glue" function (ARM->thumb) to
> call the IAP-function, which is basically correct since the IAP-function
> is thumb-code.
>
> Step though the code in "disassembly view" and check what happens after
> BX r3 at Label ??rT0x7FFFFFF1. Does it return as expected?
>
> As already mentioned: try to compile the C-source which calls the IAP
> function in thumb-mode, this should avoid the glue-function. As far as I
> can see the disassembly shows a code generated for ARM-mode.
>
> Anyway you should ask the IAR-support since this is somehow
> compiler-specific. If nothing helps, call the IAP function "manually"
> with some (inline-)assembler code

can you plz tell me in more details about how i can call IAP function
"manually".I will contact IAR-support regarding thumb mode programming.
Thank you very much for your help.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.