I am trying to interface the Nokia 6610 color LCD with a pic18F4550. I am using CCS PICC compiler for the programming of the microcontroller. I can do everything with the LCD by using software spi i.e. bit banging but when I try to do the same using hardware SPI nothing happens at all. Here is the code that i am talking about
The above code snippet uses software SPI(bit banging SPI) but when I tries to use the following the LCD is not working
I have tried all the clock frequencies in place of "SPI_CLK_DIV_16". I have even tried using timer2 at the same place but it was all in vain. I even tried using the #use SPI but still nothing happened. I tried to compile the code in two different version of CCS compilers (3.249 and 4.038) but still could not make it work. Can anybody please tell me what am i doing wrong that is preventing me from using the hardware SPI In place of the software(bit banging) SPI mode. I have set
#bit SSPEN = 0xFC6.5
The waveforms looks perfectly nice in Proteus simulation also the SPI debugger shows that the correct SPI data is being sent but when I implement it in the actual hardware it is not working. Please help.
Code:
void nokia_write_dorc(char bytefornokia) // serial write data or command subroutine
{
char caa;
for (caa=8;caa>0;caa--) {
output_low(SCK);
//delay_us(2);
if ((bytefornokia&0x80)==0){output_low(SDO);}
else {output_high(SDO);}
output_high(SCK);
bytefornokia=bytefornokia<<1;
}
}
The above code snippet uses software SPI(bit banging SPI) but when I tries to use the following the LCD is not working
Code:
void nokia_write_dorc(char bytefornokia) // serial write data or command subroutine
{
setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_CLK_DIV_16);
output_low (SDO);
//output_high (SCK);
//delay_cycles(2);
SSPEN = 1;
spi_write(bytefornokia);
//setup_spi(FALSE);
SSPEN = 0;
}
I have tried all the clock frequencies in place of "SPI_CLK_DIV_16". I have even tried using timer2 at the same place but it was all in vain. I even tried using the #use SPI but still nothing happened. I tried to compile the code in two different version of CCS compilers (3.249 and 4.038) but still could not make it work. Can anybody please tell me what am i doing wrong that is preventing me from using the hardware SPI In place of the software(bit banging) SPI mode. I have set
#bit SSPEN = 0xFC6.5
The waveforms looks perfectly nice in Proteus simulation also the SPI debugger shows that the correct SPI data is being sent but when I implement it in the actual hardware it is not working. Please help.