MASTER and SLAVE PICs using SPI in Oshonsoft

Thread Starter

camerart

Joined Feb 25, 2013
3,842
Hi,
I've been trying to get 2x PICs as MASTER SLAVE for 6months now, and still not succeeded :(

As a method of testing if the SS/CS is working, can anyone tell me that if a TOGGLING LED was in the SLAVE PIC LOOP, and the MASTER PIC didn't address it, would the LED flash?

At the moment the LED on my SLAVE PIC always flashes, but I'm sure earlier I got it to stop when not addressed,

C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,842
hi,
Have you written a bare bones program ie: One byte to and from the PICs pair.?

E
Hi E,
As a method of testing if the SS/CS is working, can you tell me that if a TOGGLING LED was in the SLAVE PIC LOOP, and the MASTER PIC didn't address it, would the LED flash?

Here are the 2x latest programs, plus the result of a Digital analysis:
C
 

Attachments

Thread Starter

camerart

Joined Feb 25, 2013
3,842
hi C,
Checking your information.
I do not see any SSPSTAT register settings/tests in either program.?
E
Hi E,
SSPSTAT has been there in past tests, but as with most settings that have been tried, this one must have been taken out.

If you add it back in, i'll test it.

(It's a bit like Eric Morcambe playing the piano :) )
Cheers, C.
 

ericgibbs

Joined Jan 29, 2010
21,462
hi C,
I have clipped and pasted the code from the video I posted, that show the program flow.
The top two images refer to the Master and two lower the Slave.

Assign the pins for the SPI connections as required , but keep the code uncluttered...o_O

If you create a couple of programs ie: Master and Slave using the same steps, I will go thru it with you when you post it.

E
 

Attachments

Thread Starter

camerart

Joined Feb 25, 2013
3,842
hi C,
I have clipped and pasted the code from the video I posted, that show the program flow.
The top two images refer to the Master and two lower the Slave.

Assign the pins for the SPI connections as required , but keep the code uncluttered...o_O

If you create a couple of programs ie: Master and Slave using the same steps, I will go thru it with you when you post it.

E
Hi E,
Thanks.
I think it is written in ' C ' and as you know I write in Oshonsoft BASIC. Can I assume that I need to [ DIM ] variables, then add the 'SPI' PINs.

In the programs, I posted in #203 are the tops of them where I ' DIM ' the variables and TRIS the PINS suitable, if I change the other settings to you suggestions?

(Been covered in caustic soda all morning, stripping a couple of gates, good day for drying them :) )
C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,842
Hi E, [ TRANSMITTER ]

SLAVE
I'm stuck on a few parts!

19F4431 doesn't accept [ ALLDIGITAL ]

OShonsoft sees [ count ] as a SYSTEM KEYWORD, is this correct or is it a VARIABLE?

I've never seen [ bytetostr ] before. I looked it up and see that it means BYTE to STRING, is it used here?

I'm not using an LCD!

Here's the program so far:
EDIT: Corrections
C
 

Attachments

Last edited:

ericgibbs

Joined Jan 29, 2010
21,462
hi,
Can you tell me how you expect this code to work.?
It bears no resemblance to the sample code I posted.
E

ss = 0 'Pull ss low to select SLAVE
SSPBUF = 236 'Load DATA and begin transfer
Wend '?????????????????????????????

While(SSPSTAT.BF) 'wait till whole Byte is transfered
temp = SSPBUF 'READ what SLAVE sent in
ss = 1 'Pull SS high to terminate transfer
While(1)
 

Thread Starter

camerart

Joined Feb 25, 2013
3,842
hi,
Can you tell me how you expect this code to work.?
It bears no resemblance to the sample code I posted.
E

ss = 0 'Pull ss low to select SLAVE
SSPBUF = 236 'Load DATA and begin transfer
Wend '?????????????????????????????

While(SSPSTAT.BF) 'wait till whole Byte is transfered
temp = SSPBUF 'READ what SLAVE sent in
ss = 1 'Pull SS high to terminate transfer
While(1)
Hi E,
This is what I get if I try this section of CODE literally.
C.
 

Attachments

ericgibbs

Joined Jan 29, 2010
21,462
hi C,
That is not my code, that code is the code from the Arduino video which I clipped for you.
The code I posted was the Draft Slave code for Oshonsoft, you must convert the Arduino Master code to OS Basic.

Do you need help doing that.?
E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,842
hi C,
That is not my code, that code is the code from the Arduino video which I clipped for you.
The code I posted was the Draft Slave code for Oshonsoft, you must convert the Arduino Master code to OS Basic.

Do you need help doing that.?
E
Hi E,
Am I correct that I use the SLAVE DRAFT.TXT as a guide for both programs, but use the [ SPI_Basic1.gif ] for each of the settings?

If this is correct I'll have a go first, thanks.
C.
 

ericgibbs

Joined Jan 29, 2010
21,462
hi C,
I named it SLAVE DRAFT.TXT in order to make it clear it was intended as a guide for the Slave PIC.
The MASTER.TXT program code must be different as it is the controlling PIC, it decides when it wants to exchange data with the Slave.

If you want the Slave to tell the Master 'I have data in my SSBUF and I am ready for data exchange ' the Slave would pull a Slave to Master I/O line Hi, [not one one of the SPI lines.] and wait for the Master.

E

Note:
The Arduino While(!BF)
is Osh
While NOT SSPSTAT.BF Wend ' it reads and loops for all 8 bits of the data exchange Byte
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,842
hi C,
I named it SLAVE DRAFT.TXT in order to make it clear it was intended as a guide for the Slave PIC.
The MASTER.TXT program code must be different as it is the controlling PIC, it decides when it wants to exchange data with the Slave.

If you want the Slave to tell the Master 'I have data in my SSBUF and I am ready for data exchange ' the Slave would pull a Slave to Master I/O line Hi, [not one one of the SPI lines.] and wait for the Master.

E

Note:
The Arduino While(!BF)
is Osh
While NOT SSPSTAT.BF Wend ' it reads and loops for all 8 bits of the data exchange Byte
Hi E,
Is this better?
C
 

Attachments

ericgibbs

Joined Jan 29, 2010
21,462
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
 

Attachments

Top