Im having some difficulties setting up software SPI on a pic 16F88 I have the following Code. I know the 88 has hardware SPI but im trying to setup software SPI on it for now.
I was hoping to get the code in C if possible as im not to familiar with assembly yet. I have downloaded various versions and read different articles on software spi. The problem is all of the examples don’t have any consistency especially when your trying to learn how it works. For instance I read an article that says you have to pull the csn bit low when your going to send information to get the slave to listen. But two different functions I have seen one pulls it low and the other sets it as high. Im also confused as to when the read takes place. It is my understanding that after your loop sends each bit. Do you immediatly follow with another loop to read the bits on the MISO line?
I think that function was originally in C and I converted it into assembler. It works with the Nordic NRF24L01 wireless chips. The original was on the SFE web site somewhere.
The only code I could find was some spi firmware for the nrf which is close to what I need but the firmware uses multiple for loops to perform the spi routines…Not exactly a send recieve function unless I missed another file some where.
I think I have everything working except my reciever is not recieving the transmitter payload but it is using different code.
Thankyou for all of your patience in helping a Noob get setup with wireless!
(The code im referring to in the Tx.c file from your zipped folder)
One last question The reciever Im using uses different code and I believe its payload width is 1 byte and the code you gave me has a payload width of 4 bytes. What are the absolute minimum requirements to get the two to talk? As I understand they have to have the same payload width as well the correct address and channel but im not entirely certain. Also what is the transmitter transmitting out? I just need it to send a character to the other reciever.
Start with my Tx and Rx code, to make sure that the receiver is working properly. You should then be able to get some transmit code working to match the receive code that you have.
As im going over the code I think i fully understand how everything works. But another question remains…The nrf accepts commands and changes in the form of:
spi(command)
spi(data)
csn =1
csn = 0
next statements…
After looking at the data sheet it seems that there are only 8 commands: