MASTER and SLAVE PICs using SPI in Oshonsoft

Thread Starter

camerart

Joined Feb 25, 2013
3,842
ho,
Look at this amendment of your code.
Note: this compiles, but it is only the very basic code, you need to add all the supporting code for the program in order for it to do any work.
E
Hi E,
With the 2x programs at #212 and 220, will they work well enough to see signals between them on a DIGITAL ANALYSER?
C.
 

ericgibbs

Joined Jan 29, 2010
21,463
hi,
Run this test code in the IDE.
Set Basic tracking ON
click SSPSTAT On/Off on the IDE micro view, hi and low , watch the byte exchange taking place in the SSBUF.
With basic tracking on you can follow the action of the code.

I have used two different Byte values so that you can see SSBUF change.
OK.?
E

EDIT:
Double checking that vid code, I believe there is an error.
Will check it and get back to you.
 

Attachments

Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,842
hi,
Run this test code in the IDE.
Set Basic tracking ON
click SSPSTAT On/Off on the IDE micro view, hi and low , watch the byte exchange taking place in the SSBUF.
With basic tracking on you can follow the action of the code.

I have used two different Byte values so that you can see SSBUF change.
OK.?
E

EDIT:
Double checking that vid code, I believe there is an error.
Will check it and get back to you.
Hi E,
I've been testing LIVE not Simulator, as I think both PICs need to be talking to get the transfer. (Correct me if I'm wrong)
Here is the result of a digital analyser scan with both PICs connected.

EDIT: The full programs that your CODE will be added to, use OSH SPI for addressing the modules, such as compass, GPS etc, will this work alongside OSH SPI?
C.
 

Attachments

ericgibbs

Joined Jan 29, 2010
21,463
hi C,
Use this for Oshonsoft IDE testing.
Of course to make work in the real project the Slave must be also programmed with a suitable Slave program
E

Get the two PIC's working with these test programs, then get started on the main program
Check that they exchange simple data correctly first.
 

Attachments

Thread Starter

camerart

Joined Feb 25, 2013
3,842
hi C,
Use this for Oshonsoft IDE testing.
Of course to make work in the real project the Slave must be also programmed with a suitable Slave program
E

Get the two PIC's working with these test programs, then get started on the main program
Check that they exchange simple data correctly first.
Hi E,
Is there any problem using a digital analyser instead of the OSH simulator?
I can set up for Simulation if necessary.
Here's the result from a LIVE test.
C
 

Attachments

ericgibbs

Joined Jan 29, 2010
21,463
hi,
I would recommend you construct a hardware test pair of PIC's, you say you have spent 6 months trying to get it working
So say 1 hour to knock up a test rig would be a wise move.
Don't forget you still have to program for the SPI error status conditions etc, so do it off line from the main project.

E

BTW: since moving to Win 10 using the previous version of Oshonsoft PIC18, I keep getting licence errors and it shuts down.
I have to uninstal and reinstall.......Osh
 

Thread Starter

camerart

Joined Feb 25, 2013
3,842
hi,
I would recommend you construct a hardware test pair of PIC's, you say you have spent 6 months trying to get it working
So say 1 hour to knock up a test rig would be a wise move.
Don't forget you still have to program for the SPI error status conditions etc, so do it off line from the main project.

E

BTW: since moving to Win 10 using the previous version of Oshonsoft PIC18, I keep getting licence errors and it shuts down.
I have to uninstal and reinstall.......Osh
Hi E, [TRANSMITTER ]
MASTER SLAVE
The Analysis in #226 is from a hardware pair of PICs on a PCB, connected to the wires between them, note MOSI and MISO.

(I also sometimes get runtime errors, then OSH shuts down, but luckily, when it starts up again, it remembers where it left off)
C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,842
hi,
Ok, the next step is to look at SSPCON1 of the 18F4620, the WCOL bit and the18F4431 SSPCON WCOL and SSPOV bits
E
Hi E,
Sorry, the programs don't appear to be working as #226. :(
I've seen that kind of false READing before, but can't remember what causes it.

I'll look for errors and try again.
C
 

Thread Starter

camerart

Joined Feb 25, 2013
3,842
hi,
Look a this WIP Slave program, its easy to converts from Arduino to Oshonsoft, try to finish it off..
E
Hi E,
Looking through this SLAVE program #210, I see
--------------------------------------------------------------------
SSPCON.SSPM2 = 1
SSPCON.SSPM1 = 1
------------------------------------------------------
2x, is this correct?
I changed it to:
-----------------------------------------------------------------
SSPCON.SSPM3 = 0
SSPCON.SSPM2 = 1
SSPCON.SSPM1 = 0
SSPCON.SSPM0 = 0
----------------------------------------------------------------
EDITED
C.
 
Last edited:

ericgibbs

Joined Jan 29, 2010
21,463
hi C,
All these settings are in the datasheets.
E

MASTER:
SSPCON1.SSPM0 = 0 ' SPI Master Mode Fosc/64
SSPCON1.SSPM1 = 1
SSPCON1.SSPM2 = 0
SSPCON1.SSPM3 = 0


SLAVE:
SSPCON.SSPEN = 1 'enable SPI pins
SSPCON.SSPM0 = 0
SSPCON.SSPM1 = 0
SSPCON.SSPM2 = 1
SSPCON.SSPM3 = 0
 

Thread Starter

camerart

Joined Feb 25, 2013
3,842
hi C,
All these settings are in the datasheets.
E

MASTER:
SSPCON1.SSPM0 = 0 ' SPI Master Mode Fosc/64
SSPCON1.SSPM1 = 1
SSPCON1.SSPM2 = 0
SSPCON1.SSPM3 = 0


SLAVE:
SSPCON.SSPEN = 1 'enable SPI pins
SSPCON.SSPM0 = 0
SSPCON.SSPM1 = 0
SSPCON.SSPM2 = 1
SSPCON.SSPM3 = 0
Hi E,
Yes, good, that's how I have them.
C
 

Thread Starter

camerart

Joined Feb 25, 2013
3,842
Hi,
Here are the latest programs:
At the moment, I am only testing for transfer of DATA between the 2xPICs, using a digital analyser, connected on the tracks between them.

Looking at the SLAVE 4431 Program, Some of the comments in the guide at #208, don't correspond to the D/S. Can someone verify please? (Marked ^^^^^^^??????????)

EDIT: The none flashing SLAVE LED is now flashing [ START UP LED ] (Something to do with TRIS set-up) but not in the LOOP. I think this tells me that the PIC is working, but it is not LOOPing the [ xfer_slave ]
EDIT
C.
 

Attachments

Last edited:

jjw

Joined Dec 24, 2013
823
In the slave you have ss=1??
I don't know what happens when input pin is written from "inside", but it is wrong anyway.
ss should be controlled by the master
 

Thread Starter

camerart

Joined Feb 25, 2013
3,842
In the slave you have ss=1??
I don't know what happens when input pin is written from "inside", but it is wrong anyway.
ss should be controlled by the master
Hi J,
I think the SS= 1 is just how it starts, so that the SLAVE is OFF, then the MASTER controls it as you suggest.
C
 
Top