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.
8 years ago.
trash data on serial connection
Hello! I have this serial connection between the nucleo and PIC. I am using the pins (PA_9,PA_10) for the RX,TX of the nucleo connected to the rx,tx of the PIC. The PIC will be sending a string message to the nucleo, but the data displayed in the serial monitor is just trash. What may be the cause of the problem?
I used the basic program for reading if there is an available data in the serial port.
#include "mbed.h" Serial pc(USBTX, USBRX); // tx, rx Serial device(PA_9, PA_10); // tx, rx int main() { while(1) { if(device.readable()) { pc.putc(device.getc()); } } }
Question relating to:
2 Answers
8 years ago.
do you connect the tx of one microprocessor to the rx of the other ? Do you define the same speed, parity ? Do you care for a common ground ? Are both microprocessor with the same logic level (3,3V) ?
8 years ago.
I think it is most likely to be a speed mismatch. If you've confirmed that the settings are right then look at the PIC clock configuration.
Just to clarify that, I would expect the Nucleo to go to 9600 baud if it isn't set. The PIC will need to be set to 9600 baud to match. Also with the PIC there is no standard clock frequency so it is important to ensure the compiler option is set correctly.
posted by 25 Apr 2016