This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52 softdevice corrupts ps/2 packets

I've been working on using an nRF52 as a host for a PS/2 synaptics touchpad mouse (to integrate with BLE HID).  I was able to get a correct mouse position using two GPIO pins (clock and data) while BLE was disabled.  

Once I turned on BLE, many of my packets were corrupted.  PS/2 is a very slow protocol (25-50 microsecond clock intervals) with a parity bit as its only consistency check.  As it turns out, the softdevice that runs the BLE stack is known for stealing CPU cycles, which seem to be the culprit.

Before I go down a rabbit hole here, I wanted to throw a few questions out:

  • Is there a way to put the BLE to sleep for a few milliseconds while I poll my PS/2 device, then wake it to send the mouse report?  (doesn't seem likely but worth a shot).
  • I'm not using interrupts for detecting the PS/2 clock pin (seemed like overkill at first).  Could this help in my case or would the softdevice still take priority?
  • Are there tweaks I can make to the BLE config or the softdevice to make it less chatty?  I'd assume it should stay quiet until it's time to send data (I'm seeing packet loss just from BLE being enabled. Peered, connected, or advertising. No other data needs to be sent)
  • Is a timeshared chip like nRF52 a bad fit for this project, or am I doing something wrong here? I would love to take advantage of nRF52's unmatched low power consumption.

The board is Adafruit Bluefruit nRF52832 Feather using the Adafruit libraries. 

Parents
  • Is there a way to put the BLE to sleep for a few milliseconds while I poll my PS/2 device, then wake it to send the mouse report?  (doesn't seem likely but worth a shot).

    Yes. You can use the Timeslot API to ask the SD for a few ms without interrupts.

    The PS/2 protocol allows the host to plull the clock line low - inhibiting device communication. This should be done outside the "time slot".

  • Wow, I had no idea that existed.

    This looks like a lot of work to implement, but it seems like the only foolproof way to ensure processor time.

    The guide I found for time slots seems to be for the nRF51, and I know there are also some implementation differences with the Adafruit libraries. 

    I'll report back here once I have something (or if I hit a brick wall) since my lessons learned could help others with similar issues. 

Reply
  • Wow, I had no idea that existed.

    This looks like a lot of work to implement, but it seems like the only foolproof way to ensure processor time.

    The guide I found for time slots seems to be for the nRF51, and I know there are also some implementation differences with the Adafruit libraries. 

    I'll report back here once I have something (or if I hit a brick wall) since my lessons learned could help others with similar issues. 

Children
No Data
Related