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.

SPI Communication using PIC as a master

Status
Not open for further replies.

awan

Advanced Member level 4
Joined
Jun 11, 2004
Messages
106
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Location
Los Angeles
Activity points
815
pic spi

Hi;

I am trying to send data from PIC16F88 to a slave Jennic Microcontroller.

PIC16F88 can only send 8bits of data on SPI in one go. But for jennic to receive data, it should first get 0x02(status) and 0x00(zero padding for Jennic to reply) and then it expects the length of data being sent before the actual data can be sent.

I am not sure but, i dont receive any data on Jennic, Can someone please guide me on this. Could it be that PIC sends data over SPI in 8bits and Jennic expects a continuous burst. I send data like this:

SSPBUF=0x02; //Status for Jennic to receive data
while(!BF);
test=SSPBUF;

SSPBUF=0x00; // Zero padding for jennic to reply
while(!BF);
test=SSPBUF;

SSPBUF=0x01; //32 bit length of word being sent
while(!BF);
test=SSPBUF;

SSPBUF=0x01; //Next 4 bits of data
while(!BF);
test=SSPBUF;

SSPBUF=0x02;
while(!BF);
test=SSPBUF;

SSPBUF=0x03;
while(!BF);
test=SSPBUF;

SSPBUF=0x04;
while(!BF);
test=SSPBUF;

Thanks,
 

daviddlc

Full Member level 5
Joined
Feb 11, 2007
Messages
260
Helped
35
Reputation
70
Reaction score
9
Trophy points
1,298
Location
USA
Activity points
2,709
spi pic

All the SPI communication happens on 8 or 9 bits, 9 bits is a special case for error checking. So 8 bits = 1byte will work.

Both controllers should have the same configuration for the SPI, same speed (Baud rate), same word lenght (8 or 9 bits), same number of stop bits, etc.

Once you are sure both have the same configuration, then the hardware connection should be correct as well.

After that the protocol between Jennic and the PIC controller should be correct.

Based on your comments:

SSPBUF=0x02; //Status for Jennic to receive data
while(!BF);
test=SSPBUF;

Here you are waiting for Jennic to reply:
SSPBUF=0x00; // Zero padding for jennic to reply
while(!BF);
test=SSPBUF;

But you are not reading that information back to make sure some communication has been established.

Let's assume that the communication between controllers is succesfull

Next you suppose to send how many byte will be sent. So if you will send 5 bytes of data you should send:
SSPBUF=0x05; //5 bytes to be sent
while(!BF);
test=SSPBUF;

Then you will send you 5 bytes, whatever the values are.

I hope this can help, perhaps you can include more information.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top