Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

SSPBUF SPI problems with PIC 16F877

Status
Not open for further replies.

ee2001

New Member
i am using the PIC 16F877 SPI mode for PIC to PIC communication between the master and slave. I have an array of characters which has a size of 10 that needs to be sent from the master to the slave. My array contains {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}.

However, what is shown on the slave is always {0, 1, 3, 5, 7, 9}. It skipped the numbers 2 4 6 and 8. I suspect that something is wrong in the SSPBUF register.

We have look at various forums and tried out their methods but none of them seem to be working.

Pls help us. Thank you for your time and effort. attached are the data sheet for the PIC 16F877 and the coding in C for Master and Header File for the pre settings for SPI MODE.
 
These are the routines (for Master SPI) we have used on the past to write and read. By definition; the read on the master requires a write (since the write is what initiates the clock).

Code:
Proc spi_send(spi_data As Byte)
	SSPBUF = spi_data
	While SSPSTAT.BF = 0
	Wend  'Wait until buffer is clear
End Proc
Code:
Function spi_receive(spi_data As Byte) As Byte
	SSPBUF = spi_data
	While SSPSTAT.BF = 0
	Wend  'Wait until buffer is clear
	spi_receive = SSPBUF
End Function
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top