Yahoo Groups archive

Lpc2000

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

Message

Re: [lpc2000] Calling IAP-routines from thumb mode

2006-01-23 by Tom Walsh

conrado wrote:

>Hi Guys,
>
>I try to call the IAP-routines from ARM-mode with help of the code 
>to enter THUMB-mode from the file section:
>
>static void callIAP(void)
>{
>  // fast way to get the address of flashParams[] directly into r0
>  register void *pFP asm("r0") = flashParams;
>
>  asm volatile(" mov r1, r0\n"          // copy &flashParams[] into 
>r1
>               " bx  %[iapLocation]"    // 'bx' because IAP is Thumb 
>mode
>               :
>               : "r" (pFP), [iapLocation] "r" (IAP_LOCATION)
>               : "r1" );
>}
>
>The code runs fine, the IAP is entered in thumb mode and returns to 
>ARM-mode again. Only nothing happens: when I try to read the Part Id 
>(command 0x36) it returns 0. The same for the Boot Code (command 
>0x37). R0 / R1 points to the (same) FlashParams. With help of the 
>debugger I see the 0x36/0x37-commands in these parameters are 
>overwritten by zero.
>
>  
>
I dunno, mine works and I didn't bother with ASM:

======== begin C call to ID ============

#define  IAP_LOCATION            0x7ffffff1

typedef void (*IAP)(unsigned int [],unsigned int[]);
unsigned int command_iap[5], result_iap[3];
IAP   iap_entry;


static int iapCommand (iap_calls_t command, int parm1, int parm2, int parm3)
{ // execute ISP similar command via IAP calls.
   iap_entry = (IAP) IAP_LOCATION;
   switch (command) {
...
...
      case IAP_READ_PART_ID:
         command_iap [0] = 54;
         disableIRQ(); iap_entry(command_iap,result_iap); enableIRQ();
         return result_iap[1];
...
...
    }
    return False;
}


=========== snip =================

Regards,

TomW

-- 
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net, http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------------------------------------------

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.