Another thing...
From looking at the code you don't appear to be using the SPI SS slave select pin. You should. As the master lowers/raises this pin around every byte transfer it re-syncs the bit counter. If you don't use it then if you get one clock glitch on the slave you will be out of sync forever.
This can occur right from startup as the master and slave setup their SPI hardware... without it you're at the mercy of which side powers up first and initializes its pins.
You can look at the
TB3265 app note for some ideas, but even this glosses over many of the issues I've pointed out, simply stating things like "A slave must always be available and has to wait until the master pulls its SS channel low" without any hints as to how to go about doing that.
Hi T,
As you know I've been playing with writing and reading memories, but even though it looked like I was succeding, I'm not sure quite, what was happening, because the Oshonsoft simultator drop downs, didn't confirm my actions.
You looked at the CODE, I pressume you mean at #19. I've been using itterations around this CODE fro months and as mentioned , getting out of sync.
I'm now going back to this type of CODE, which work (not in sync) to try your suggestions in more detail.
The MASTER does use a C/S-SS which can interrupt the SLAVE at any time, while other things are going on in the LOOP.
The DATA has been PARSED into an array (below). The DATA I'm interested in tranferring is S2M(). (SLAVE 2 MASTER)
In the #19 CODE are lines:
------------------------------------
While Not SSPSTAT.BF
Wend
-------------------------------
at both sides of the SPI. Does this do the job of the WAIT that you mentioned?
Looking at the CODES in #19, remembering that there is a C/S, how would you change it?
C
Code:
's2m(0) = "£" '£ [TOT 35 BYTES ]
's2m(1) = gps(7) 'Time
's2m(2) = gps(8) 'Time
's2m(3) = gps(9) 'Time
's2m(4) = gps(10) 'Time
's2m(5) = gps(11) 'Time
's2m(6) = gps(12) 'Time
's2m(7) = gps(14) 'Time
's2m(8) = gps(15) 'Time
's2m(9) = gps(19) 'Lat
's2m(10) = gps(20) 'Lat
's2m(11) = gps(21) 'Lat
's2m(12) = gps(22) 'Lat
's2m(13) = gps(24) 'Lat
's2m(14) = gps(25) 'Lat
's2m(15) = gps(26) 'Lat
's2m(16) = gps(27) 'Lat
's2m(17) = gps(27) 'Lat
's2m(18) = gps(28) 'Lat
's2m(19) = gps(30) 'N
's2m(20) = gps(32) 'Lon
's2m(21) = gps(33) 'Lon
's2m(22) = gps(34) 'Lon
's2m(23) = gps(35) 'Lon
's2m(24) = gps(36) 'Lon
's2m(25) = gps(38) 'Lon
's2m(26) = gps(39) 'Lon
's2m(27) = gps(40) 'Lon
's2m(28) = gps(41) 'Lon
's2m(29) = gps(42) 'Lon
's2m(30) = gps(44) 'W
's2m(31) = POSCNTL 'QEIDEGLB
's2m(32) = POSCNTH 'QEIDEGHB
's2m(33) = 12 'Bat volt
's2m(34) = 123 'Spare DATA