Shop OBEX P1 Docs P2 Docs Learn Events
Generating "bidirectional synchronous serial" — Parallax Forums

Generating "bidirectional synchronous serial"

SRLMSRLM Posts: 5,045
edited 2008-11-09 21:33 in Propeller 1
Hello,

I'm working through the PS/2 interface, and it requires a bidirectional synchronous serial protocol. My first thought (and supported by subsequent research) is that FullDuplexSerial.spin would work for this. However, the protocol requires a signal line and a clock line, while the FullDuplexSerial just takes a tx pin and a rx pin. What am I overlooking?

Comments

  • AleAle Posts: 2,363
    edited 2008-11-09 20:28
    I was just looking to implement it for the xmos. Chip's source of the keyboard driver provides little explanaton, this page:

    http://www.computer-engineering.org/ps2protocol/

    has the missing bits. One clock line driven by the device, one data line driven either by the device or the host. Both ends of the data line should be open-collector with input buffers. You just simulate this using a PIN as output only when needed (when sending a '0') and turning it into input when the line needs to be pulled high.

    I hope it helps

    Ale
  • SRLMSRLM Posts: 5,045
    edited 2008-11-09 21:15
    Yeah, I found those pages a little while ago, and that's where I got the phrase. I understand the principle, I'm just lost on how to implment it on the propeller. I'm not adverse to writting some new code, but my main problem is the timing between the clock signal and the data signal. I can have a method toggle the clock pin, and I can have a method toggle the data pin, but doing both at the right time? Tough... (for me at least.)
  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-09 21:33
    Usually the data line has to be stable before the clock edge, so you set the data line before you toggle the clock line. Look at the SHIFTOUT/SHIFTIN code in the BS2 compatibility library from the Object Exchange. It's intended for implementing an SPI interface which is synchronous serial.

    FullDuplexSerial will not work for this because it's intended for asynchronous serial communications, not synchronous. The approximate clock is specified by the Baud and the synchronization is done using a start and stop bit with the leading edge of the start bit marking the start of a bit time. The stop bit will ensure that the start bit leading edge can be recognized.
Sign In or Register to comment.