Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: IAP command problems

2004-10-05 by Stephen Pelc

>    Date: Mon, 04 Oct 2004 10:53:43 -0000
>    From: "helmutbitter" <helmut.bitter@...>
> Subject: Re: IAP command problems

1) The code below is what we use to call IAP from ARM code.

2) It is solid providing that you have upgraded to the 
v1.52/1.63 bootloader.

3) it works fine from Flash or from RAM.

4) The pointer to cmd in on the R12/psp stack, and the pointer 
to res is in R10/tos. The return stack is R13/rsp.

Stephen


l: ^IAP
  IAPentry 1 or ,			\ entry address, Thumb 
mode

code IAP	\ *cmd *res --
\ *G The primitive to call the IAP routines. Interrupts are
\ ** disabled for the duration of the IAP call.
  str	link, [ rsp, # -4 ] !		\ save return address

\ Disable interrupts
  mrs   r0, cpsr			\ save interrupt status
  str   r0, [ rsp, # -4 ] !
  orr   r0, r0, # $C0			\ disable interrupts
  msr   cpsr, _c r0

\ Set up parameters and call the IAP Thumb routine
  ldr   r0, [ psp ], # 4		\ R0 = *cmd
  mov   r1, tos				\ R1 = *res
  stmfd rsp ! { r9-r12 }		\ preserve regs
  ldr   r12, ^IAP			\ get entry address
  mov   link, pc			\ link set to after BX
  bx    r12				\ jump to Thumb code
  mov   r0, r0				\ probably unnecessary
  mov   r0, r0
  mov   r0, r0
  mov   r0, r0
  ldmfd rsp ! { r9-r12 }		\ restore regs

\ restore interrupts
  ldr   r0, [ rsp ], # 4
  msr   cpsr, _c r0

  ldr   tos, [ psp ], # 4		\ restore TOS
  ldr   pc, [ rsp ], # 4		\ return
end-code

--
Stephen Pelc, stephen@...
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 23 80 631441, fax: +44 23 80 339691
web: http://www.mpeltd.demon.co.uk - free VFX Forth downloads

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.