Hi
The following is a trivial routine. Function: Using the SSI controller, write a byte of data (dat) into the SSI (Synchronous Serial Interface)(Luminary LM3S9B96) Tx register(actually a FIFO) and flush the Rx register(also a FIFO) by reading it. Works fine no problem... but the compliler (correctley) says:
Fatfs\port\fm_mmc.c(65): warning: #550-D: variable "rcvdat" was set but never used.
Any ideas on how to keep the code tight (can't see how you can make it tighter... - using direct pointers to the registers) and - stop it complaining?
#define HWREGB(x) (*((volatile unsigned char *)(x))) #define HWREG(x) (*((volatile unsigned long *)(x))) #define SSI0_BASE 0x40008000 // SSI0 // etc void XmitSsi (unsigned char dat) { unsigned char rcvdat; // Write dat // Wait until there is space. while(!(HWREG(SSI0_BASE + SSI_O_SR) & SSI_SR_TNF)){} // Write to the SSI. HWREGB(SSI0_BASE + SSI_O_DR) = dat; // Flush Recieve FIFO // Wait until there is data to be read. while(!(HWREG(SSI0_BASE + SSI_O_SR) & SSI_SR_RNE)){} // Read data from SSI. rcvdat = HWREGB(SSI0_BASE + SSI_O_DR); }
In embedded programming, it's not uncommon to have a situation like this where it's the act of reading that's important - not the value read.
Therefore, it'd be really useful if Keil had a specific feature to support this; eg, a #pragma unused ?
"Therefore, it'd be really useful if Keil had a specific feature to support this; eg, a #pragma unused ?"
Agreed.
#pragma diag_suppress can be used to suppress all instances of a specified message - maybe extend that to suppress the specified warning just for a specific symbol...?
www.keil.com/.../armccref_CIHECIAD.htm http://www.keil.com/support/man/docs/armcc/armcc_Chdcgaie.htm