Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 3 months ago.
I'm trying to make a uart communication with nucleo f401re
Hello, I just started using nucleo f401re and mbed.
I'm trying to build a system to control servo motor which uses uart system.
Before making the final design i'm experimenting with Serial library to implement design but keeps failing.
Here's the code I made,
Serial Practice
#include "mbed.h" DigitalOut myled(LED1); Serial motor(USBTX, USBRX); char* start = "10139444"; int main() { motor.format(8, Serial::None, 1); motor.baud(115200); while(1) { myled = 1; motor.printf(start); wait(1); myled = 0; motor.printf(start); wait(1); } }
My question is, if i change the pins of motor led doesn't turn on. For example if I change the satement
Serial motor(USBTX, USBRX); to Serial motor(D1, D0); the code doesn't seem to run.
What't the reason for my failure?
Thanks in advance.
1 Answer
9 years, 3 months ago.
By default, Arduino header pins D0 & D1 are disconnected on all Nucleos. Instead, Serial2 Tx/Rx are routed to the ST-Link board to give debug output over USB to host PC.
Refer to http://developer.mbed.org/platforms/ST-Nucleo-F401RE/ and choose other pins for your motor connection.eg Serial1 Tx/Rx on D8/D2.
Full schematics of the Nucleos are in http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00105823.pdf