5 years, 8 months ago.

Connect another board over UART from nRF51822 mKit board

First of all I would like to thank mbed team for providing such a fantastic library. This is the first time I am writing any MCU application and it sure makes things a lot easier.

I am using nRF51822 mKit board. https://mbed.org/platforms/Nordic-nRF51822/

I was able to compile and run BLE_API examples without any problem. I was also able to use pc UART to print debug messages.

Now I want to control/connect to another board. The other board also has UART. I am following the code from this page. https://mbed.org/handbook/SerialPC

nRF51822 allows to use any pair of GPIO to be used as UART. The thing I am not clear is, can I have two active UART. Serial pc(USBTX, USBRX); Serial uart(p27, p28);

I tried this and I could not communicate with other board. I am connecting TX -> RX and RX->TX. It doesn't seem to be working. For hypothesis testing, I want to use nRF51822 mKit board as transparent bridge to control other device.

#include "mbed.h"
 
Serial pc(USBTX, USBRX);
Serial uart(p27, p28);
 
DigitalOut pc_activity(LED1);
DigitalOut uart_activity(LED2);
 
int main() {
    while(1) {
        if(pc.readable()) {
            uart.putc(pc.getc());
            pc_activity = !pc_activity;
        }
        if(uart.readable()) {
            pc.putc(uart.getc());
            uart_activity = !uart_activity;
        }
    }
}

Any help is appreciated.

Any updates on this?

posted by Bert Kruger 31 Oct 2014

It has been a while so I am not 100% sure. However one of the issue I overlooked was the default baud rate for the other device. After correcting that issue I was able to communicate with other device. I am no longer working on this project but I "believe" nRF51822 has only one UART controller so you can only have one UART.

posted by Jigar Patel 31 Oct 2014

2 Answers

4 years, 4 months ago.

I verified and this device has only one uart module.

4 years, 4 months ago.

if you want to use more than one serial, you can easily port any uart library that does bit-bangin. (software implemented uart). please note that it will keep your cpu occupied for much longer than a hardware-based solution.