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.
7 years, 8 months ago.
UART - Nucleo STM32F411
Hi Guys i have problem with Nucleo using Serial or BufferSerial (similar test done with arduino it work without problem but in Nucleo Stm32F411Ret6 not)
i connected one (Nucleo1) STM32F411RET6 in PC another one (Nucleo2) STM32F411RET6 connected to the first ones via 5V / GND and D2/D8 (UART TX,UART RX) see picture for description
Code used to Nucleo1 is
include the mbed library with this snippet
**/* Nucelo 1 - code */** #include "mbed.h" #include "BufferSerial.h" Serial PC(USBTX, USBRX); BufferSerial Device(PA_9, PA_10); int main() { PC.baud(57600); Device.baud(57600); while(true) { if (Device.readable()) { while (Device.readable()) { uint8_t MyValues = Device.getc(); if (MyValues == 13) { PC.printf("\n\n"); PC.printf("%02x,", MyValues); } else { PC.printf("%02x,", MyValues); } } } wait_ms(50); } }
Code used to Nucleo 2 is
include the mbed library with this snippet
/* Nucleo 2 - code */ #include "mbed.h" #include "BufferSerial.h" BufferSerial Device(PA_9, PA_10); int main() { Device.baud(57600); uint8_t cmd1[] = { 0x0d, 0xaa, 0x01, 0x00, 0x00, 0x00, 0x27 }; uint8_t cmd2[] = { 0x0d, 0xaa, 0x01, 0x02 }; uint8_t cmd3[] = { 0x0d, 0xaa, 0x01, 0x00, 0x27 }; uint8_t cmd4[] = { 0x0d, 0xaa, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27 }; while(true) { Device.write(cmd1, sizeof(cmd1), 0, 0); wait_ms(50); Device.write(cmd2, sizeof(cmd2), 0, 0); wait_ms(50); Device.write(cmd3, sizeof(cmd3), 0, 0); wait_ms(50); Device.write(cmd4, sizeof(cmd4), 0, 0); wait_ms(50); } }
But it give me wrong results (or i missing something) like below : ???
instead to receive in Serial Monitor results
0x0d, 0xaa, 0x01, 0x00, 0x00, 0x00, 0x27,
0x0d, 0xaa, 0x01, 0x02,
0x0d, 0xaa, 0x01, 0x00, 0x27,
0x0d, 0xaa, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27,
I receive something like :
0x0d, 0x00, 0x00, 0x00, 0x01, 0x1f,0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27 0x27, 0x27, 0x27 0x27, 0x27, 0x27 0x27 0x27,0xaa,0xaa .... (one long row until i get another 0x0d which start with new line)
Assigned to
7 years, 7 months ago.This means that the question has been accepted and is being worked on.
Could you try a faster baudrate (115200) and also increasing the value of wait_ms between the .write. Note: For the Nucleo2 you don't need BufferedSerial work only with Serial, you are only sending.
Best regards
posted by Felícito Manzano 10 Jul 2017I need to use that speed of communication with other devices but i face problem that i tried to simulate with nucleo 2
(similiar test on arduino work as well it could read from nucleo2 info without problem)
posted by VALON HOTI 11 Jul 2017Problem resolved in non usually way with change of hardware clock *for uart port only so the code belove work without problem as READER.
SENDER now is defined in this way too
what is strange is this part of code for changing clock of uart communication droping it on half this one helped me to have good communication between devices
this part was been resolved into :
https://developer.mbed.org/questions/54029/USART-Problem-with-NucleoF401RE/
posted by VALON HOTI 26 Jul 2017