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);
PROVIDE( MEMAP = 0xE01FC040);
then in a header file
/* SYSTEM CONTROL BLOCK */
/* MAM */
extern unsigned char MAMCR;
extern unsigned char MAMTIM;
extern unsigned char MEMAP;
And to reference them in a source file, after including the appropriate
header of course,
MAMCR = (unsigned char)ctrl; /*lint !e930 cast from enum */
MAMTIM = (unsigned char)cycle_time;
I find that 'cleaner' than pointer de-references. YMMV The biggest
disadvantage is you end up depending on both the ld file and the header
file. I don't know how the code generation compares.
You can see this in the newlib-lpc source.
Robert
" 'Freedom' has no meaning of itself. There are always restrictions, be
they legal, genetic, or physical. If you don't believe me, try to chew a
radio signal. " -- Kelvin Throop, III
http://www.aeolusdevelopment.com/Message
Re: [lpc2000] accessing SPI registers
2005-05-25 by Robert Adsett
Attachments
- No local attachments were found for this message.