Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
# Printing using the USB Debugger
On the discovery board there in issue with using Printf statements for debugging.
We are able to make use of a USB to serial Debugging cable to work around this.
## Connecting the Cable
You will need to connect the debugger to the board using output PINs.
| Cable | Role | Pin |
|-------|------|------|
| White | RX | PA_2 |
| Green | TX | PA_3 |
If the board is already connected via USB (for uploading code), there
is no need to connect the power and ground pins.
## Code for Printing
We first need to setup the Serial Connection.
~~~c
#include "mbed.h"
Serial serial(PA_2,PA_3);
~~~
We can then print using the ```serial.printf()``` statements.
Demonstration Code below:
~~~
#include "mbed.h"
Serial serial(PA_2,PA_3);
// tx, rx
int main() {
//serial.baud(115200);
serial.printf("Hello World!\n\r");
while(1) {
wait(1);
serial.printf("Hello World!\n\r");
}
}
~~~
## Configuring the Serial Monitor
You may also need to configure the serial monitor to listen on the correct port.
We can do this by modifing the platformio.ini file to include
~~~
monitor_port = /dev/ttyUSB0
~~~