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

UART on Custom board

Hi there,

I am trying to use UART on the nRF52840 on a custom PCB. The custom board is connected to the nRF52840-DK with a debug connector. Am I free to set any pins on the chip as the RX, TX, etc? I was just going to use a scope to see if data is going through the UART on the custom board as expected.

ETA: It seems like I've set up the PSEL registers fine. I've set the Baudrate to 115200 but looking at the registers, it says the baud rate is 2576384 ??? There is also an event error but I'm not specifically what the error is.

I'm working from the SDK15 UART example. Please advice.

Thank you

  • Hi.

    You can use any free GPIO pin as TX or RX for UART, list of GPIO pins is here.

     

    ETA: It seems like I've set up the PSEL registers fine. I've set the Baudrate to 115200 but looking at the registers, it says the baud rate is 2576384 ??? There is also an event error but I'm not specifically what the error is.

     Have you set the baudrate in sdk_config.h?

    They are defined in sdk_config.h as the following:

    // <323584=> 1200 baud 
    // <643072=> 2400 baud 
    // <1290240=> 4800 baud 
    // <2576384=> 9600 baud 
    // <3866624=> 14400 baud 
    // <5152768=> 19200 baud 
    // <7729152=> 28800 baud 
    // <8388608=> 31250 baud 
    // <10309632=> 38400 baud 
    // <15007744=> 56000 baud 
    // <15462400=> 57600 baud 
    // <20615168=> 76800 baud 
    // <30924800=> 115200 baud 
    // <61845504=> 230400 baud 
    // <67108864=> 250000 baud 
    // <123695104=> 460800 baud 
    // <247386112=> 921600 baud 
    // <268435456=> 1000000 baud 

    So if you want the baudrate equal to 115200, you have to define it like this:

    #ifndef NRFX_UART_DEFAULT_CONFIG_BAUDRATE
    #define NRFX_UART_DEFAULT_CONFIG_BAUDRATE 30924800

    If you use the nrfx UART driver, if you use the UART library, define the following:

    #ifndef UART_DEFAULT_CONFIG_BAUDRATE
    #define UART_DEFAULT_CONFIG_BAUDRATE 30801920
    #endif

    Best regards,

    Andreas

  • Thanks for this!

    I am trying to use a sensor that needs 9600 baud rate, and that's what I set it to on the sdk_config.h. Would I still be able to see the transmit/receive data on putty if the baud rate is set to 9600 and the DK runs on 115200? At the moment, I can only see things on putty if the baud rate is set to 115200.

    I'm having trouble with getting any responses from the sensor, both from the custom PCB and just connecting the sensor to the assigned GPIO pins on the DK. I am able to send commands to the sensor ie "Z\r\n" but I am not getting the right response back from the sensor. In this case, the temperature reading. 

    What am I doing wrong here?

Related