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.
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,
There is [ SSPCON = %00100100 ] in SLAVE also, should I remove that too?
C
 
On the master idle state is 0.
What is defined on the slave
Hi J, [TRANSMITTER ]
SLAVE (NO) SSPCON.........OK.

My SPI CLOCK question was a bit vague, what I meant to ask is more the SPI settings. I haven't understood the difference between Hardware and software, and why one is chosen over the other?

How is CHIP SELECT set? Do all the settings match in the attached jpg?
C.
 

Attachments

  • SPI Switching.jpg
    SPI Switching.jpg
    157 KB · Views: 222
Hi J, [TRANSMITTER ]
SLAVE (NO) SSPCON.........OK.

My SPI CLOCK question was a bit vague, what I meant to ask is more the SPI settings. I haven't understood the difference between Hardware and software, and why one is chosen over the other?

How is CHIP SELECT set? Do all the settings match in the attached jpg?
C.
Oshonsoft Basic has functions for SPI master. It is implemented in software ( bit banged)
There are no Basic functions for SPI slave.
The HW master could be used by setting SSPCON, SSPSTAT, but why to introduce a new source for possible errors.
The software master has been used before in your program, pressure transducer, compass, lcd and it is working.
I think the chip select in master is controlled by SPICSOn, SPICSOff
 
Oshonsoft Basic has functions for SPI master. It is implemented in software ( bit banged)
There are no Basic functions for SPI slave.
The HW master could be used by setting SSPCON, SSPSTAT, but why to introduce a new source for possible errors.
The software master has been used before in your program, pressure transducer, compass, lcd and it is working.
I think the chip select in master is controlled by SPICSOn, SPICSOff
Hi J,
I almost get it, thanks.

I think the CHIP SELECT is still a bit vague, as there are settings for it in the D/S, and it's not clear to me where the Oshonsoft
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Define SPI_CS_REG = PORTX
Define SPI_CS_BIT = X
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
would be used.
C.
 
I think it is better use directly PORTX.X = 0 instead of SPICSOn and not use Define SPI_CS_REG =.... because you have CS for multiple SPI devices.
Same for SPICSOff.
 
I think it is better use directly PORTX.X = 0 instead of SPICSOn and not use Define SPI_CS_REG =.... because you have CS for multiple SPI devices.
Same for SPICSOff.
Hi J,
Previously, I've used [ SPICSOn/OFF ] also a CS set-up earlier in the program e,g, [ Symbol altmtr = LATD.1 ]

But looking through the latest programs, I've noticed that SPICSON is before CS. I'll change them to the correct order tomorrow, and report back.
C.

SPICSOn
SLAVEpic = 0
'SLAVE PIC ON (NOTE SLAVE is CAPITAL LETTERS?)
SPISend 5
SPIReceive DATA
Hserout "5= ", #DATA, CrLf
SPISend 10
SPIReceive DATA
Hserout "10= ", #DATA, CrLf
SLAVEpic = 1 'SLAVE PIC OFF
SPICSOff
 
Only in Slave!
Don't touch hw SPI in master :)
Hi J [ TRANSMITTER ]
Only in SLAVE, OK.

"Don't touch HW SPI in MASTER" OOoops. I've been trying all sorts of things.

At the moment, only SLAVE is HSEROUTing
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
SLAVE:
LOOP:

Toggle yled
WaitMs 200

Hserout "4431DATA= ", DATA, CrLf
Hserout "4431azilb= ", azilb, CrLf
Hserout "4431#DATA= ", #azilb, CrLf

Goto LOOP
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
NOTE: The TX for the HSEROUT is the same PIN as SLAVE CS.

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
MASTER:
SLAVEpic = 0 'SLAVE PIC ON
SPICSOn
SPISend DATA
SPISend azilb
SPICSOff
SLAVEpic = 1 'SLAVE PIC OFF
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If I comment out [ SLAVEpic = 0/1 ]
then the SLAVE LED keeps flashing, but the HSEROUT stops.

I think this means that the CS is working, do you?

I've been sending various SPISENDs, but nothing shows on the SLAVE HSEROUT yet.

There is noise on all SPI SLAVE PINS.
C.
 
Hi J,
This link looks like it was successful does it match our settings?

I can't understand the language properly.
C.
 
Hi J [ TRANSMITTER ]
Only in SLAVE, OK.

"Don't touch HW SPI in MASTER" OOoops. I've been trying all sorts of things.

At the moment, only SLAVE is HSEROUTing
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
SLAVE:
LOOP:

Toggle yled
WaitMs 200

Hserout "4431DATA= ", DATA, CrLf
Hserout "4431azilb= ", azilb, CrLf
Hserout "4431#DATA= ", #azilb, CrLf

Goto LOOP
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
NOTE: The TX for the HSEROUT is the same PIN as SLAVE CS.

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
MASTER:
SLAVEpic = 0 'SLAVE PIC ON
SPICSOn
SPISend DATA
SPISend azilb
SPICSOff
SLAVEpic = 1 'SLAVE PIC OFF
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If I comment out [ SLAVEpic = 0/1 ]
then the SLAVE LED keeps flashing, but the HSEROUT stops.

I think this means that the CS is working, do you?

I've been sending various SPISENDs, but nothing shows on the SLAVE HSEROUT yet.

There is noise on all SPI SLAVE PINS.
C.
You have to outputs on the same pin at slave : hserout, slave ss
Try to print spireceive at master
 
You have to outputs on the same pin at slave : hserout, slave ss
Try to print spireceive at master
Hi J, [ TRANSMITTER ]

"You have two outputs on the same pin at slave : hserout, slave ss" True, I made a NOTE #132 (It could be a problem, but there's no choice)

"Try to print spireceive at master" I've tried many MASTER HSEROUT SPIRECEIVES, and now trying to see if there's anything in SLAVE first. NOTE: DIGITAL ANALYSER shows DATA -->-->SLAVE
C
 
Last edited:
Hi J,
Am I correct that even though PIN 44 on SLAVE is for SS/CS, it can be changed as we're not using Oshonsoft SPI CS?
C
 
In #132

LOOP:
Toggle yled
WaitMs 200

Hserout "4431DATA= ", DATA, CrLf
Hserout "4431azilb= ", azilb, CrLf
Hserout "4431#DATA= ", #azilb, CrLf

Goto LOOP

Where have Data been read?
When printing it use #Data
 
It can't be changed in HW Slave unless there is an alternate pin for it.
Hi J, [ TRANSMITTER ]
Ok.

SLAVE: I doubt then that HSEROUT can be used at the same time as CS.

Is there another way to indicate that DATA has been SENT by MASTER and RECEIVED in SLAVE at the SLAVE end?

EDIT: I'll remove the HSEROUT from SLAVE and try LED flash if DATA>100
C.
 
Last edited:
Hi J,
#139 That didn't work, and I'm out of ideas!

Would you be interested in posting some programs, that I can test?
C.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top