Serial works only when PC UART terminal is connected

09 Jul 2018

Hello everyone,

I am using nRF51-DK board with ARM Mbed IDE. I am detecting pulses at P0.09(UART Tx Pin) on the oscilloscope only when UART terminal is connected otherwise not. PFB code .

And when I disconnecting from UART terminal , Pulses at P0.09 are stopped. May I know why this is type of working & what should I do to receive pulses at P0.09 even when UART terminal is not connected on the PC.

Secondly, I want to change serial port pin from P0.09 & P0.11 to P0.25 & P0.24 without Hardware flow control. What should I do for that ??.

#include "mbed.h"
#include "Serial.h"

#define NEED_CONSOLE_OUTPUT 0 // Set this if you need debug messages on the console;
                              // it will have an impact on code-size and power consumption. 
#if NEED_CONSOLE_OUTPUT
#define DEBUG(...) { pc.printf(__VA_ARGS__); }
#else
#define DEBUG(...) // nothing 
#endif // #if NEED_CONSOLE_OUTPUT 

Serial RN42(USBTX,USBRX);

void RN42_init(void);

void RN42_init(void) {     
        
     RN42.format(8,SerialBase::None,1);
     
     RN42.baud(9600);
     
     wait(0.25);                
}  

int main(void) {
    
    wait(1.0f);         
    RN42_init(); 
    
    while(1) {
    
        RN42.putc('A');
        RN42.printf("Hello World\n\r");
        wait(1.0f);            
    }   
}    
03 Aug 2018

Hi Bharat,

To answer your first question, the UART is half duplex communication and it won't function unless both Receiver (RXD) and Transmitter (TXD) pins are connected. Since you disconnected from PC the UART protocol can't verify or establish the connection.

Second, you cannot change the pins from P0.09 & P0.11 to P0.25 & P0.24 directly from mbed since the UART pins have been predefined to act as Virtual COM port with the interface MCU. You can look this up at the link below up at the link below (Section 4.2). http://infocenter.nordicsemi.com/pdf/nRF51_DK_UG_v1.1.pdf