This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.
See the CrossGCC FAQ for lots more infromation.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Art - On Wed, 28 Jun 2000, Art Berggreen wrote: > Have you tried declaring your hardware variables as "volatile"? This > tends to stop the compiler from many of these optimizations. > (i.e. try #define IoPortAddr (volatile (BYTE*)0xa0001)) Thanks for the suggestion. At present, I'm using two types of construction: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= [...] #define EVB_BASE 0xFFFF0000 /* Register-block base address */ /* SCI0 Registers */ /* Serial mode ch 0 */ #define SCI0_SMR (*(volatile unsigned char *)(EVB_BASE + 0x81a0)) /* Bit rate ch 0 */ #define SCI0_BRR (*(volatile unsigned char *)(EVB_BASE + 0x81a1)) [...] then I read or write from appropriately typed or cast variables { unsigned char tempch; ... tempch = SCI0_SMR | <modes_to_add>; SCI0_SMR = tempch; ... } =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= and in other sources: [...] #define readb(addr) (*(volatile unsigned char *) (addr)) #define writeb(b,addr) ((*(volatile unsigned char *) (addr)) = (b) #define SCI0_SMR (EVB_BASE + 0x81a0) used as in: { ... unsigned char tempch; tempch = readb(SCI0_SMR); writeb((tempch | <modes_to_add>), SCI0_SMR); ... } =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= The second approach is handy in that registers may be grouped as unions and manipulated jointly or severally without duplicated variant names nor in-line type-casts (or rather the type casting looks like functions, which I find handy and readable - YMMV). I haven't found any construction which seems to work or fail consistently, but my 'C' coding skills are (to put it gently) 'limited'. I'll try the formation you suggest and see how it works. I am also concerned by the inconsistent results I seem to get from code constructions which (_a_priori_) look acceptable to me. Regards - John Mills Sr. Software Engineer TGA Technologies, Inc. 100 Pinnacle Way, Suite 140 Norcross, GA 30071-3633 e-mail: jmills@tga.com Phone: 770-441-2100 ext.124 (voice) 770-449-7740 (FAX) ------ Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |