nRF52840DK uart - 921600 not working

I’m using the nRF52840DK to communicate with a module over uart. My problem is that the module has a baud rate of 921600 and as far as my understanding the nRF52840 is using a baud rate of 941176 when set to 921600.  This leads to my commands (13 bytes) only works around 10-20% of the times, and the data received is not as expected (startbytes etc.).

I have tried using nrf_serial_flush as well but then nothing works. Also tried setting the baud rate manually without succeeding.

Any tips?

  • What I find strange is when sending data to my module (which is a LiDAR) and at the same time reading this data with the usb-2-ttl the bytes is perfect, yet the LiDAR is not responding. I would assume the usb-2-ttl module shows a bit more flexibility in terms of baud rate.

    I have tried contact the manufacturer of the LiDAR without luck, but I will try to reach out to them again.

    Just to clarify it is not possible to “tune” the baud rate to get it more accurate?

     

    Thanks for the help!

  • Hi,

    Stig24 said:
    What I find strange is when sending data to my module (which is a LiDAR) and at the same time reading this data with the usb-2-ttl the bytes is perfect, yet the LiDAR is not responding. I would assume the usb-2-ttl module shows a bit more flexibility in terms of baud rate.

    It is a bit odd, but that could be it.. Which exact LiDAR module are you using? Could it be something else, like a flow control issue? (just an idea without any particular reason for thinking that would be related). Is it possible to use flow control with the module? If so, can you try it?b

    Stig24 said:
    Just to clarify it is not possible to “tune” the baud rate to get it more accurate?

    No, the values from the product specification is the closest you can get. There is one thing though, which I have forgot to mention before. Note that there are different values for the UART (without DMA) and UARTE (with DMA) peripheral. So depending on which you use, you need to pick the correct one (see baud rate table in PS for that).

  • Is it possible to measure the external clock frequency?

  • The HFXO frequency? Not directly (probing on the crystal will shift the frequency), but you can output a fraction of the frequency using a TIMER and GPIOTE connected via PPI. And then use a frequency counter to measure it.

    That is probably overkill for this, though. A simple way to check if the frequency is sensible (and more than enough for UART) is to just program a BLE peripheral example and try to connect to it. If that works, it must be more or less as it should be, as if not the radio frequency would be too much off.

  • I see, do you have an example code for this?

    You mention that the baud rate was due to a WH limitation, can you elaborate more?

Related