Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Hardware SPI not working in PIC18F4550

Status
Not open for further replies.

jitun

Newbie level 2
Joined
Nov 21, 2006
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,300
pic18f4550 spi

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

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.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top