Offload Bitbanging from main processor (NRF9160)

Hi!

In my project i am using a motion sensor that uses a custom protocol. This has resulted in needing to implement bitbanging for it to work. The issue with this is that it takes resources from the main processor and halts other tasks that need to be done (due to the thread being occupied). I tried to see if the nrf9160 had any Programmable Real-Time Units (PRUs) but could not find any. My question is if there is any other way to offload the bitbanging from the main processor. Any tips are appreciated!

  • Hello,

    Can you please share some details regarding the custom protocol that you are trying to bit-bang? Depending on what it looks like, we can investigate to see if there are any tools/hacs that could work for your case.

    Best regards,

    Edvin

  • Hi Edvin,

    Yes, the sensor is the pyd1589 from excelitas technologies. I have attached the datasheet to this message and you can find the specification here: https://www.excelitas.com/product/pyd-1588-pyd-1598-low-power-digipyros?filename=PYD%201588%20Datasheet.pdf. Essentially, the protocol uses a 1-wire interface for configuration (SERIN) and data readout (Direct Link). The SERIN interface requires precise timing for data clocking, while the Direct Link interface has a 22 µs bit time and specific timing for readout operations.

    Thanks in advance,
    Ray

    PYD_1598_Low-Power_DigiPyro_datasheet.pdf

  • Ok, I see.

    For the serial in I would say it is probably possible to use an SPI instance or something, and just ignore the clock pin. The data readout is a bit tricky. UART will not work, because it has no stop bits. SPI could work, but the problem is that you don't know when to sample. 

    Yes, this is a though one, unfortunately. It is not clear to me from the datasheet, but it looks like you even have to drive the serial pin even if you are using interrupt reading. Is that correct?

    You could experiment with SPI and trying to read. You can adjust the time between the serial output and when you start the SPI read, but if you get another high priority interrupt in the meantime, then that measurement will be lost. 

    Are you aiming for interrupt reading or forced read? And if you use interrupt reading, do you need to use the serial pin (Direct Link) as an output from the nRF at some point?

    BR,
    Edvin

  • Yes, it is true that you have to have to drive the serial pin even if you are using interrupt reading. But we are actually not using interruptread mode, just wakeup and forcedread mode. Essentially, we have a system that sleeps and is woken up by the motion sensor. We use forced mode just to make sure that the configuration is right before sleeping again.

    It seems however that another solution than what has already been implemented will be too complicated. The codes runtime is just 1ms anyways and is just run at the start when the system wakes up. Therefore the current solution isn't really detrimental and i was mostly curious if there was another simpler way Slight smile. Thanks for the help!

Related