RS485 testing on the Anthem PCB
Dependencies: mbed
Fork of Serial_HelloWorld_Mbed by
main.cpp@1:7a5b1550838c, 2014-08-21 (annotated)
- Committer:
- bgrissom
- Date:
- Thu Aug 21 18:19:13 2014 +0000
- Revision:
- 1:7a5b1550838c
- Parent:
- 0:879aa9d0247b
This program successfully works for communicating to the Anthem PCB via the Sparkfun RS485 converter with a terminal program at 9600 Baud.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 0:879aa9d0247b | 1 | #include "mbed.h" |
bgrissom | 1:7a5b1550838c | 2 | |
bgrissom | 1:7a5b1550838c | 3 | // 2014.08.21 |
bgrissom | 1:7a5b1550838c | 4 | // Brad Grissom |
bgrissom | 1:7a5b1550838c | 5 | // This program successfully works for communicating to the Anthem PCB |
bgrissom | 1:7a5b1550838c | 6 | // via the Sparkfun RS485 converter with a terminal program at 9600 Baud. |
bgrissom | 1:7a5b1550838c | 7 | |
mbed_official | 0:879aa9d0247b | 8 | |
bgrissom | 1:7a5b1550838c | 9 | |
bgrissom | 1:7a5b1550838c | 10 | Serial pc(PB_6, PB_7); // tx, rx |
bgrissom | 1:7a5b1550838c | 11 | DigitalOut LeftTX_EN(PA_12); |
mbed_official | 0:879aa9d0247b | 12 | |
mbed_official | 0:879aa9d0247b | 13 | int main() { |
bgrissom | 1:7a5b1550838c | 14 | int get = 0; |
bgrissom | 1:7a5b1550838c | 15 | LeftTX_EN = 1; |
bgrissom | 1:7a5b1550838c | 16 | // ORIG: pc.baud(9600); |
bgrissom | 1:7a5b1550838c | 17 | // The clock on the Anthem board is running faster than the Nucleo, |
bgrissom | 1:7a5b1550838c | 18 | // so one hack is to slow down our baud rate. This runs at 9600 baud |
bgrissom | 1:7a5b1550838c | 19 | // on the scope. |
bgrissom | 1:7a5b1550838c | 20 | pc.baud(6400); |
bgrissom | 1:7a5b1550838c | 21 | |
mbed_official | 0:879aa9d0247b | 22 | while(1) { |
bgrissom | 1:7a5b1550838c | 23 | // pc.printf("U"); |
bgrissom | 1:7a5b1550838c | 24 | // wait_ms(10); |
bgrissom | 1:7a5b1550838c | 25 | |
bgrissom | 1:7a5b1550838c | 26 | LeftTX_EN = 0; |
bgrissom | 1:7a5b1550838c | 27 | wait_ms(1); |
bgrissom | 1:7a5b1550838c | 28 | get = pc.getc(); //+ 1; |
bgrissom | 1:7a5b1550838c | 29 | |
bgrissom | 1:7a5b1550838c | 30 | LeftTX_EN = 1; |
bgrissom | 1:7a5b1550838c | 31 | wait_ms(1); |
bgrissom | 1:7a5b1550838c | 32 | pc.putc(get); |
bgrissom | 1:7a5b1550838c | 33 | wait_ms(2); |
mbed_official | 0:879aa9d0247b | 34 | } |
mbed_official | 0:879aa9d0247b | 35 | } |