trouble with synchronous serial receive
I'm attempting to make a basic keyboard code reader for the PS/2 click, and running into an issue. The protocol looks like this: https://www.researchgate.net/figure/PS-2-protocol-involved-in-the-keyboard-to-computer-communication_fig7_220848551 A clock signal is usually high, and pulses low when data is available. 11 bits are used: 1 start, 8 data, 1 parity, 1 stop. At first I was manually checking the pin values but I was told about the synchronous serial receive smart pin option which sounded like a more intelligent way to do things.
From the propeller manual, "When a word is received, IN is raised and the data can then be read via RDPIN/RQPIN." My problem is, IN is always 1, if I'm understanding how to read it correctly.
A snipped of code here:
CON PIN_KEY = 32 ' keyboard data input PIN_CLK = 33 ' keyboard clock input _CLKFREQ = 250_000_000 VAR hitKey ' what key is currently hit PUB Start()|startTime,tempk,deltaTime PinFloat(PIN_KEY) PinFloat(PIN_CLK) WRPin(%0000_1001_000_0000000000000_00_11101_0,PIN_KEY) ' synchronous serial receive on PIN_KEY, with inverted clock on PIN_KEY+1 WXPin(%11010,PIN_KEY) ' read 11 bits of data coincident with clock edge hitKey := 0 startTime := getms() repeat repeat ' use synchronous serial receive to grab bits off the pin, if available. if PinRead(PIN_KEY) == 1 ' there's data waiting tempk := RDPin(PIN_KEY) if tempk <> 0 hitKey := 1 deltaTime := getms()-startTime while deltaTime < 50 'do something with hitKey here
My understanding is PinRead is used as a flag in smart pin mode to say that data has been received. However, it appears to always be 1, whether or not I'm typing on the keyboard. I tried inverting the clock signal, but that didn't have an effect. Is there something else I'm missing (not setting something right, some other command, etc), or is my understanding of this smart pin method incorrect?