Hi,
I am trying to implement a PS/2 bit banging driver. My initial attempt used the GPIO library and interrupts, but unfortunately the interrupts are not fast enough and oftentimes there are transmission errors due to missed bits.
Now I am exploring whether it would be possible to use PPI to read the data.
PS2 uses a clock and data pin. The data pin is read on the falling edge of the clock pin. The frequency is approximately 10-16hz.
The PS2 data frame is 11bit:
- Start bit
- 8 data bits
- Parity bit
- Stop bit
I considered trying to use SPI, but it seems that it can‘t read odd number of bits.
Now I’m exploring whether PPI would work.
My idea is…
-
Create a timer that counts whenever the clock pin triggers.
- Copy the data pin value to some kind of buffer every time the clock pin triggers
- When the timer reaches 11, copy the buffer using easy DMA to the cpu and trigger an interrupt to notify it.
- Reset the timer counter so that it can start from scratch
Is something like this feasible?
If yes, could you please point me to some documentation on how to configure such PPI tasks? I couldn’t find any good explanations.
I was able to find examples for counting, but not for storing the data pin value in a buffer array and for transmitting it using easy DMA.
Thank you so much,
Kim