Yahoo Groups archive

Lpc2000

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

Message

Re: [lpc2000] accessing SPI registers

2005-05-26 by Bruce Paterson

Robert Adsett wrote:

> At 11:37 AM 5/25/05 -0400, Brett Delmage wrote:
> 
>>Now, can anyone tell me if there is clean, way to generate faster code than:
>>
>>#define REG(addr) (*(volatile unsigned long *)(addr))
>>#define REG8(addr) (*(volatile char *)(addr))
>>
>>in gcc? I don't like the multiple instruction to generate the address
>>each access, but maybe that is typical/not bad. I'm
>>relatively new to ARM and RISC.
> 
> 
> I haven't done a comparison of code generation but I use ld in combination 
> with gcc for this.
> 
> IE in the appropriate ld control file I have something like
> 
> /* SYSTEM CONTROL BLOCK */
>          /* MAM */
> 
> PROVIDE( MAMCR = 0xE01FC000);
> PROVIDE( MAMTIM = 0xE01FC004);

> then in a header file
> /* SYSTEM CONTROL BLOCK */
>          /* MAM */
> 
> extern unsigned char MAMCR;
> extern unsigned char MAMTIM;

> You can see this in the newlib-lpc source.

Incidentally Robert, I had to add a couple of volatiles to the 
newlib-lpc lpx2XXX.h file in my case where you'd left them out (but most
registers had them). Probably for a case you weren't expecting, but I 
was re-programming PINSEL registers before sleeping.

Gcc had done a trick of moving the updates around since not specified 
volatile and of course it had weird (and non-obvious) results. Only
found the problem eventually by looking at the assembly code.

May be worth having a thought experiment on any other non-volatile 
registers specified.

-- 
Cheers,
Bruce
-------------------------------------------------------------------
     /\\\/\\\/\\\    /   /      Bruce Paterson
    /  \\\ \\\ \\\  /   /    Senior Design Engineer
   /   /\\\/\\\/\\\/   /   8 Anzed Court, Mulgrave, Vic, 3170
  /   /  \\\ \\\ \\\  /  PO Box 4112, Mulgrave, Vic, 3170, Australia
/   /    \\\/\\\ \\\/   Ph: +61 3 8561 4232   Fax: +61 3 9560 9055
       Tele-IP Ltd.      Email: bruce@...    Icq: #32015991
                         WWW:   http://www.tele-ip.com       VK3TJN
-------------------------------------------------------------------

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.