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

How can i change RX TX pin of UART?

Hello, because of my mistake, rx tx pin was not cross connected.

So i want to swap rx tx pin on nrf51822.

In the example ble_app_uart_s130_pca10028, i change the code in main.c

const app_uart_comm_params_t comm_params = { RX_PIN_NUMBER, //RX_PIN_NUMBER=11 TX_PIN_NUMBER, //TX_PIN_NUMBER=9; RTS_PIN_NUMBER, CTS_PIN_NUMBER, APP_UART_FLOW_CONTROL_ENABLED, false, UART_BAUDRATE_BAUDRATE_Baud38400 };

to

const app_uart_comm_params_t comm_params = { 9, 11, RTS_PIN_NUMBER, CTS_PIN_NUMBER, APP_UART_FLOW_CONTROL_ENABLED, false, UART_BAUDRATE_BAUDRATE_Baud38400 };

After upload the firmware, i test uart using nRF Toolbox app.

  1. disconnect rx tx pin physically, pairing BLE -> well paired.
  2. connect rx tx pin physically -> Error 6:The connection has timed out unexpectedly occur and break the pairing.

Why this error is occur?

When i try not swapped code(origin example) crossing rx tx pin on MCU,

this error is not occurred.

Parents
  • Is this on the PCA10028 board, or a custom board? On PCA10028, nRF51 pin 11 (RX) is connected to TX of J-Link virtual serial port, and pin 9 (TX) is connected to RX of J-Link virtual serial port.

    When you are swapping these two in your main.c, it will mostly likely cause an error as the pins are hard-wired, and the J-link is pulling up one of these pins (speculating). If you need to do a loop-back test, you can use any other freely available pins that are not hardwired, short them, and disable flow control.

    In case you are using a custom board and swapping these pins, then make sure you have the BOARD_CUSTOM flag set in the compiler. Also you have flow control enabled, so take care of that as well (on custom board).

  • Thanks psharma, you are right. I change the APP_UART_FLOW_CONTROL_DISABLED the source is well run. Thank you. I appreciate it.

Reply Children
No Data
Related