Permalink
Cannot retrieve contributors at this time
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?
KPIT_MBED_worksheet/Notes/USB_Debugger.md
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
65 lines (38 sloc)
1.13 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
~~~ |