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.

  • well it depends how you are doing your delays. If you're using nrf_delay then, no, you are just going to drift constantly. If you use a timer instead you can correct the interval you 'wait' for each bit. If you look at the softdevice spec you'll see what the max time it could interrupt for you might be, I think you'll find even 4800 baud won't bitbang reliably. I'd try interrupt driven at the highest priority available and see how you do.

Reply
  • well it depends how you are doing your delays. If you're using nrf_delay then, no, you are just going to drift constantly. If you use a timer instead you can correct the interval you 'wait' for each bit. If you look at the softdevice spec you'll see what the max time it could interrupt for you might be, I think you'll find even 4800 baud won't bitbang reliably. I'd try interrupt driven at the highest priority available and see how you do.

Children
No Data
Related