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.

  • doubt that's going to work very well, at least not when you have the softdevice running as it will be interrupted constantly and your timings will drift. Interrupts won't help you much in that case either as they too can get delayed. Unless you are using a slow baud rate and using one of the timers to make sure, even if you process one bit late (due to something interrupting you) you stay basically synchronized, bitbanging the uart isn't going to work too well.

    If you're not using the softdevice, you'll probably get away with it.

Reply
  • doubt that's going to work very well, at least not when you have the softdevice running as it will be interrupted constantly and your timings will drift. Interrupts won't help you much in that case either as they too can get delayed. Unless you are using a slow baud rate and using one of the timers to make sure, even if you process one bit late (due to something interrupting you) you stay basically synchronized, bitbanging the uart isn't going to work too well.

    If you're not using the softdevice, you'll probably get away with it.

Children
No Data
Related