spi_write(0x00); //Put data need to send into the output buffer
while(!spi_data_is_in());
{
spi_data_recieved = spi_read();
}
Am I correct?
Please advise on this code format.
I will appreciate if any kind soul can pass me his working sample for my reference.
Thanks.
gip_mad
Joined: 23 Aug 2008 Posts: 24 Location: Italy
Posted: Wed Sep 03, 2008 8:49 am
There are a lot of working examples in the "examples" folder of your compiler...
RLScott
Joined: 10 Jul 2007 Posts: 465
Re: SPI problem, please advise
Posted: Wed Sep 03, 2008 10:04 am
The CCS library functions are really setup for the master mode only. For example, the function spi_write() probably does more than just load the SSPBUF. But in slave mode that's all you want to do. I suggest that for slave mode you write directly to the SSPBUF register instead of using the CCS library functions. See the 16F887 Microchip datasheet for details.
The code you have written shows that you understand the principles of master and slave mode operation just fine. The only difficulty is knowing exactly what each CCS library function really does. Personally I would not bother using library functions for this, except maybe for the initializations. For everything else, it is easier to talk directly to the registers. _________________ Robert Scott
Real-Time Specialties
Embedded Systems Consulting
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum