Hi all
I have got a problem on my code :
#include “mbed.h”
#include “atoh.h”
Serial pc(SERIAL_TX, SERIAL_RX);
DigitalOut led(LED2);
int main()
{
pc.format(8,SerialBase::None,1);
pc.baud(2250000);
while(1) {
char c = pc.getc(); // Read hyperterminal
if (c == '0') {
led = 0; // OFF
if (pc.writeable()) {
pc.printf("OFF\t");
}
}
else if (c == '1') {
led = 1; // ON
if (pc.writeable()) {
pc.printf("ON\t");
}
}
else {
pc.printf( "%c = 0x%x\t",c,c);
}
}
}
Hi simply make a LED turn on if I send ‘1’ in the terminal, turn off if I send ‘0’ or send the character pressed if not.
It works correctly for a baud rate at max 2.25 MHz, but when I try to do it higher, for instance 4 or 8 Mhz, I just get on the terminal wrong characters, which do not correspond to what I send.
I looked on the internet and some say that maybe it was a problem of clock linked to the USART3, but I found that the clock is 48 MHz here, which would work…
I just linked my NUCLEO with my PC through a USB-Micro wire to make serial communication.
If someone has any suggestion, it would be nice.
Thanks.