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

NRF52 Interfacing sensor with serial through UART

I have a sensor with serial protocol of 7 bits data, even parity, 2 stop bits. I wanted to use uart library to interface with this sensor. But I couldn't find the settings to change data bits, even/odd parity or number of stop bits. Is it possible to do so with uart library? Or I have to write functions by myself to read bit by bit? Thanks

Parents
  • No. If you check the UART specs you'll see it only supports 8 bit with one parity bit (or none). I believe that's even parity but I can't see where it says so. The old nRF51 series let you supply your own parity bit, which might have helped you on writes, but the nRF52 doesn't and it wouldn't help you on reads anyway.

    So you'll have to do it another way.

  • Hi RK, I'm using softdevice and baud rate is 4800. I believe I begin to see the issue you mentioned. The sensor itself can output data every 60ms. I set up a timer with 200ms interval. It worked fine. But when I decreased the interval to 100ms, it stopped working randomly after some time. There was a very high chance when I connected/disconnected the device to my phone. I guess because of activities of softdevice, it lost a few bits and got stuck in some loop. Is there a better way to implement the whole thing?

Reply
  • Hi RK, I'm using softdevice and baud rate is 4800. I believe I begin to see the issue you mentioned. The sensor itself can output data every 60ms. I set up a timer with 200ms interval. It worked fine. But when I decreased the interval to 100ms, it stopped working randomly after some time. There was a very high chance when I connected/disconnected the device to my phone. I guess because of activities of softdevice, it lost a few bits and got stuck in some loop. Is there a better way to implement the whole thing?

Children
No Data
Related