Tool/software: Code Composer Studio
Hi, I was trying to control my TFT-LCD by using hardware SPI. While using software SPI, LCD can dsiplay with nothing wrong.
The only difference in my code between them is that if #define USE_HARDWARE_SPI, the WriteData function will use SPI module or it will use software SPI.
Here's my code about SPI configuration, actually I referred to the example code:
void SPI_Init(void){
InitSpiaGpio();
SpiaRegs.SPIFFTX.all=0xE040;
SpiaRegs.SPIFFRX.all=0x204f;
SpiaRegs.SPIFFCT.all=0x0; //delay=0
SpiaRegs.SPICCR.all =0x0007; // Reset on, rising edge, 8-bit char bits
SpiaRegs.SPICTL.all =0x0006; // Enable master mode, normal phase,
// enable talk, and SPI int disabled.
SpiaRegs.SPIBRR =0x007F;
SpiaRegs.SPICCR.all =0x0087; // Relinquish SPI from Reset
SpiaRegs.SPIPRI.bit.FREE = 1; // Set so breakpoints don't disturb xmission
}
void SPI_WriteData_Hardware(unsigned char Data){
Uint16 temp,clear;
temp=Data;
SpiaRegs.SPITXBUF=(temp<<8);
while(SpiaRegs.SPIFFRX.bit.RXFFST !=1) { }
clear=SpiaRegs.SPIRXBUF;
}
The problem is that when I build the project, ccs will give a warning:
variable "clear" was set but never used.
In fact, when I run it step by step, the program can run the last step in function SPI_WriteData_Hardware. But the lcd still cannot display. I thought SPI maybe where the problem is.
Could you help me? Thanks so much.