• 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.

Transfering DATA between two pics via SPI OSHONSOFT

Pommie

Well-Known Member
Most Helpful Member
If you click your name in top right corner, I believe it's under the privacy tag.

Mike.
 

jjw

Member
I think you have changed something.
Make a simple test.

SPIsend 5
SPIreceive data
Hserout data
SPIsend 10
SPIreceive data
Hserout data
Change the slave to do nothing:
In the slave after the settings and leds blinking.
loop:
goto loop

The master should print 5 and 10
 

camerart

Active Member
Hi, [ TRANSMITTER ]
Testing 2x PICs on 2x PCB is tricky, and prone to accidental reading errors by me.

MASTER: I've realised that, if a VARIABLE is SENT then RECEIVED, then HSEROUT, it may never have left the MASTER, but looks as if it has been SENT/RECEIVED.

C.
 
Last edited:

jjw

Member
SPIsend data always sends. I have checked this in the simulator.
Try SPIsend 0, then SPIreceive data.
If you still get data=255, then SDI is stuck at 1 or SSBUF in slave is always 255.
Check SDI, SDO at master and slave, SCK at master.
 

camerart

Active Member
SPIsend data always sends. I have checked this in the simulator.
Try SPIsend 0, then SPIreceive data.
If you still get data=255, then SDI is stuck at 1 or SSBUF in slave is always 255.
Check SDI, SDO at master and slave, SCK at master.
Hi J, [ TRANSMITTER ]
As I want to avoid misunderstandings, I'll be a bit pedantic:

In MASTER I'll try SPIsend 12 (Avoiding ' 0 ' as I sometimes get ' 0 ') then SPIreceive data, then HSEROUT "4620DATA= ", #DATA, CrLf


EDIT: Result
I'll try changing SSPBUF in SLAVE

EDITEDIT: Same result.
SLAVE SSPBUF =13
C.
 

Attachments

Last edited:

jjw

Member
In the slave you have now
loop:
goto loop
before SPI slave is initialized, so slave does not respond.
To test, move the loop before '' get count
You have also set QEI interrupts.
Remove them because there are no interrupt routines for them.
 

jjw

Member
I looked sdi, sdo, clk, ss tristates settings at slave and they look ok.
Have you checked the connections between master-slave.
Can you watch the signals from master: clock, sdo, sdi.
 

jjw

Member
You have in master SSPCON1 = %0010000, which sets hw SPI but you are using in Oshonsoft software master, they may interact. Remove it and test again.
 

camerart

Active Member
You have in master SSPCON1 = %0010000, which sets hw SPI but you are using in Oshonsoft software master, they may interact. Remove it and test again.
Hi J,
:arghh:Added missing vias to CS track:arghh: no change
Removed SSPCON1 = %0010000 from master no change.

Next, get the logic analyser out.
C
 

camerart

Active Member
Measure next from the slave.
Hi J,
The two PICS are surface mount and the tracks I measured are between the 2x PICs. The analyser clips, only clip on wires, so won't connect to PICs.

I previously checked PIN to PIN, and how I found the missing Vias.

C
 

EE World Online Articles

Loading

 
Top