PDA

View Full Version : Synchronous Comms



BobEdge
- 21st August 2007, 16:53
Hi,
Just a quick question.

If i wish to send 16 bits of data can i extract 1 bit like this?

datapin = temp[loop]

where temp is the word to send, and loop is a for next loop from 0 to 15

and receive in a similar way

temp[loop] = datapin

Darrel Taylor
- 21st August 2007, 19:56
Bits, Bytes Words and Arrays (melanie)
http://www.picbasic.co.uk/forum/showthread.php?t=544
<br>

BobEdge
- 22nd August 2007, 12:53
Thanks for the info Darrel, some very interesting stuff there. Still cant get it to work but I'll keep on trying.

Darrel Taylor
- 22nd August 2007, 14:53
You may also want to look at the SHIFTIN and SHIFTOUT commands.
<br>

Darrel Taylor
- 22nd August 2007, 15:21
Oops, I see in your other thread you've already tried SHIFTIN/OUT.

Something like this might be a start...

; -- Master Transmit --
For loop = 0 to 15
datapin = temp.0[loop]
clkpin = 1
PauseUS 100
clkpin = 0
Next loop

; -- Master Receive --
For loop = 0 to 15
clkpin = 1
PauseUS 100
datapin = temp.0[loop]
clkpin = 0
Next loop
;________________________

; -- Slave Transmit --
For loop = 0 to 15
while clkpin = 0 : wend
datapin = temp.0[loop]
while clkpin = 1 : wend
Next loop

; -- Slave Receive --
For loop = 0 to 15
while clkpin = 0 : wend
temp.0[loop] = datapin
while clkpin = 1 : wend
Next loop

This way is "Driven" on both ends. Be sure to have a resistor (1K is good) in the Data line between the 2 PICs.
<br>