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.

[SOLVED] Problem with SPI between two PIC 18F452s

Status
Not open for further replies.

UroBoros

Advanced Member level 2
Advanced Member level 2
Joined
May 5, 2004
Messages
642
Helped
19
Reputation
38
Reaction score
8
Trophy points
1,298
Location
Cochin - India
www.uroborostech.in
Activity points
6,463
I am doing a code to communicate between two 18F452s
One master and one slave.
packet is 25 byte length.
It is interrupt based. to exchange data only thing I need to do is load the first byte of my 25 byte array. the rest will be automatically done in SPI interrupts. 25 bytes are landiing safely at the slave side from master.
But the master is getting only an echo of what is send. when the received byte is being retrieved in interrupt in slave, I am loading the byte to be send in SSBUF. But seems it is not being accepted for sending. I think I am missing some aspect of SPI.

Thanks
 

Re: SPI between two MCUs

Are you getting problem while reading the slave? I think without understanding the protocol I can't answer, so please elaborate.



Cheers,
Akhil Kumar
 

Re: SPI between two MCUs

It's not clear what you are trying to do, or what you are expecting. You say that the data is arriving at the slave; this implies that
1) The host is sending data properly, and
2) The slave is receiving data properly.

What is your problem? What do you mean by "the master is getting only an echo". Is the slave transmitting its received data back to the host? Is that what you WANT the slave to do?
 
Re: SPI between two MCUs

Ok. I will detail.
The master is sending 25 bytes properly and slave is receiving them properly. That part is ok.
But I am returning the same amount of data, that is 25 bytes from slave to master in the same link.(simultaneous as master sending).
ie at the slave interrupt, after getting one byte from master, i am loading SSPBUF with a byte for the master.It should reach master as master sending next byte. (Anything wrong with my assumption?). That returning payload is not being received in master. That is my problem.
Thanks for your time
 

Re: SPI between two MCUs

1) Are you using an interrupt on the MASTER to indicate when it receives data? Is that interrupt enabled?
2) Are you receiving no data, or corrupt data at the master?
3) Have you looked at your signals with an oscilloscope to verify the slave is actually sending data?
4) You need to make sure you've got your data lined up properly and you've got your configuration registers setup properly. I'm not quite clear on how this chip handles it, but it looks like it uses SSPBUF for both transmitted and received data, so you need some way of ensuring that you're not writing data to SSPBUF at the same time that the received data is being transferred into it.
 
Re: SPI between two MCUs

1. Yes. on this interrupt of one byte completion , I am loading the next byte till all 25 is gone!
2.I am receiving data in correct order. No messing up, but instead of data loaded from save , what is received is the same data send to slave. That is even though SSPBF is loaded in slave, it is not accepted. so it seems.
3.Not tried on a scope yet.
4.Data is lined up properly. SSPBUF is double buffered. I am taking data at slave(which is as expected) and immediately loading SSPBUF as the payload for next transfer from slave. But that is not 'accepted' , or so it seems. Whatever already there, is going back.
Thanks
 

Re: SPI between two MCUs

I have soldered pullup resistors to data and clock lines. It is Ok now.
But still one problem. if i start both of them (MCUs) together. All ok. If I reset the master,, then slave data will not reach master. Then I need to reset slave also. Then again all ok. Slave reset no issue, but if I reset master, then slave also should be reset. Will look into that . But so far ok for the purpose.
Thanks
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top