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.

Transfering DATA between two pics via SPI OSHONSOFT

Status
Not open for further replies.

Attachments

  • OOps.jpg
    OOps.jpg
    25.5 KB · Views: 289
If you click your name in top right corner, I believe it's under the privacy tag.

Mike.
 
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
 
Hi, [ TRANSMITTER ]
Here's the result from these 2x programs:
C
 

Attachments

  • 18f4431 8MHz TX SLAVE QEI SPI 180719 0930.bas
    3.3 KB · Views: 287
  • 18F4620 8MHz XTL TX QEI 180719 0930.bas
    3.4 KB · Views: 300
  • RESULT.jpg
    RESULT.jpg
    49.6 KB · Views: 278
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:
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.
 
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

  • Result.jpg
    Result.jpg
    66.5 KB · Views: 277
Last edited:
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.
 
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.
Hi J,
Here's the latest SLAVE program:
Here's the result:
C.
 

Attachments

  • 18f4431 8MHz TX SLAVE QEI SPI 180719 1700.bas
    3.4 KB · Views: 280
  • Result.jpg
    Result.jpg
    33.1 KB · Views: 267
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.
 
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.
 
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
 
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.
Hi J,
Here's the Logic from PCB.
C
 

Attachments

  • Logic.jpg
    Logic.jpg
    194.3 KB · Views: 277
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
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top