Syncing SSPBUF in Oshonsoft.

jjw

Joined Dec 24, 2013
823
Hi J,

Hi J,
There is a [
[ While Not SSPSTAT.BF (1 = Receive complete, SSPBUF is full)
Wend ]
also in the SLAVE.
C
Yes I know.
How does the master know, when the slave PIC is ready to receive.
Or the slave to know, when the master has started to send.
I think here is the need of some protocol for the SPI

I assume, that the program in the slave is doing other things like reading the encoder etc.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,831
Yes I know.
How does the master know, when the slave PIC is ready to receive.
Or the slave to know, when the master has started to send.
I think here is the need of some protocol for the SPI

I assume, that the program in the slave is doing other things like reading the encoder etc.
Hi J,
The MASTER sets the PIC SPI SLAVE C/S.
The PIC as SLAVE C/S section only READS and WRITES the series of BYTES, then comes out of the C/S
The MASTER goes through all of the C/S in turn READing the DATA from the series of other SLAVE peripherals.
C
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,831
Hi,
Back from a break!

From previous suggestions:
Some of the incomming messages from perohperals, are a continuous stream, and some start with a $, so WAIT for a $ (in those cases)
In this case the message should be in the PIC SLAVE PERIPHERAL, starting at a particular address (In this case 0x20) and (In this case from £ to W)

Here is the 'working' buffer READ from the ALTIMETER peripheral, so the ADDRESS is sent and READ.
------------------------------------------------------------------
altmtr_cs = 0 'ALTMTR_CS ON
For i = 0 To 24
rd_adr = 0x88 + i '00=WRITE 80=READ
WaitUs 1
SSPBUF = rd_adr
While Not SSPSTAT.BF
Wend
WaitUs 1
b(i) = SSPBUF
Next i
--------------------------------------------------------------------------
In this case: the address needs to be sent in a similar way, as the SLAVE is being READ, but also the MASTER needs to send DATA too.
How would this be done?
Perhaps in 2x sections, or can it be in the same WRITE READ section?
C
 
Last edited:

Ian Rogers

Joined Dec 12, 2012
1,136
I am still unclear about this
addr = 0x20

If you send 0x20 and the slave gets S2M(0x20) that is decimal 32 two bytes from the end of the string!!

If the slave is sending array information, then the master should request index 0 ~ 34
if the slave is sending fixed variable location, only then can the master ask for 0x20 ~ 0x42..

I would need to see a snippet of the code sent to the SPI transfer routine on both sides.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,831
I am still unclear about this
addr = 0x20

If you send 0x20 and the slave gets S2M(0x20) that is decimal 32 two bytes from the end of the string!!

If the slave is sending array information, then the master should request index 0 ~ 34
if the slave is sending fixed variable location, only then can the master ask for 0x20 ~ 0x42..

I would need to see a snippet of the code sent to the SPI transfer routine on both sides.
Hi I,
Regarding the 0X20, this is the 1st ADDRESS where the SLAVE puts the S2M() DATA, naturally, so the MASTER SENDs this ADDRESS in the SPI, to READ the DATA in the SLAVE at that address, in the same way that all the other peripherals do, and increments through the 35 BYTES.

Here's an example of how the MASTER reads the SLAVE, so I'm trying to copy the method, with the PIC SLAVE.
----------------------------------------------------------------------------------
rd_adr = 0x80 'READ 0x00 %10000000
WaitUs 1
SSPBUF = rd_adr
While Not SSPSTAT.BF
Wend
--------------------------------------------------------------
EDITED
C
 

Attachments

Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,831
Hi,
I've managed to get all of the PIC SLAVE DATA STRING into an address ARRAY, starting at 0x20 35XBYTES long.

I'm not sure if I did it correctly, but I followed the OSH instructions to put the BYTEs into EEPROM memories.
I think this may be ok, although maybe RAM would be better, but I'll need to figure out how to do that.
C
 
Top