test code for bridging between USB virtual serial and UART3(PTC17, PTC16).
Dependencies: BufferedSerial mbed
Update
This issue has been fixed on GitHub.
https://github.com/mbedmicro/mbed/commit/1519466bc8536b5445e01175b16d1cd1967782a9
Serial Bridge between USB and UART3(PTC17, PTC16)
Why I share such a simple project?
There's an issue in serial format function of FRDM64K mbed library. Setting stop bit to 1 ends up stop bit 2 in serial controller register. See line 13 in main.cpp
uart3.format(8, Serial::None, 1>>1);
To set stop bit as 1, third parameter should be 0.
Hope this issue will be fixed future release.
main.cpp@0:9b5cfe4cb65e, 2015-02-16 (annotated)
- Committer:
- mizmit1222
- Date:
- Mon Feb 16 05:50:47 2015 +0000
- Revision:
- 0:9b5cfe4cb65e
first commit (modem)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mizmit1222 | 0:9b5cfe4cb65e | 1 | #include "mbed.h" |
mizmit1222 | 0:9b5cfe4cb65e | 2 | #include "BufferedSerial.h" |
mizmit1222 | 0:9b5cfe4cb65e | 3 | |
mizmit1222 | 0:9b5cfe4cb65e | 4 | BufferedSerial pc(USBTX, USBRX); |
mizmit1222 | 0:9b5cfe4cb65e | 5 | BufferedSerial uart3(PTC17, PTC16); |
mizmit1222 | 0:9b5cfe4cb65e | 6 | |
mizmit1222 | 0:9b5cfe4cb65e | 7 | int main() { |
mizmit1222 | 0:9b5cfe4cb65e | 8 | pc.puts("\r\nscissors\r\n"); |
mizmit1222 | 0:9b5cfe4cb65e | 9 | |
mizmit1222 | 0:9b5cfe4cb65e | 10 | uart3.baud(115200); |
mizmit1222 | 0:9b5cfe4cb65e | 11 | uart3.format(8, Serial::None, 1>>1); |
mizmit1222 | 0:9b5cfe4cb65e | 12 | |
mizmit1222 | 0:9b5cfe4cb65e | 13 | while (true) { |
mizmit1222 | 0:9b5cfe4cb65e | 14 | if (pc.readable()) { |
mizmit1222 | 0:9b5cfe4cb65e | 15 | char c = pc.getc(); |
mizmit1222 | 0:9b5cfe4cb65e | 16 | uart3.putc(c); |
mizmit1222 | 0:9b5cfe4cb65e | 17 | } |
mizmit1222 | 0:9b5cfe4cb65e | 18 | while (uart3.readable()) { |
mizmit1222 | 0:9b5cfe4cb65e | 19 | char d = uart3.getc(); |
mizmit1222 | 0:9b5cfe4cb65e | 20 | pc.putc(d); |
mizmit1222 | 0:9b5cfe4cb65e | 21 | } |
mizmit1222 | 0:9b5cfe4cb65e | 22 | } |
mizmit1222 | 0:9b5cfe4cb65e | 23 | } |