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.
5 years, 1 month ago.
Serial attach with Nucleo L432KC doesn't work
This code says hello but never stop blinking when one char is sent to Nucleo L432KC
- include "mbed.h"
- define TX_PIN USBTX
- define RX_PIN USBRX
- define BRATE 921600
- define LED_PIN LED0
- define TOGGLE_RATE (0.5f)
- define BUFF_LENGTH 4
Serial test_connection(USBTX, USBRX,BRATE);
volatile bool blinking = true;
DigitalOut LED(LED1); uint8_t rx_buf[BUFF_LENGTH + 1];
void blink(void) { if (blinking) { LED = !LED; } }
void serialCb() {
blinking = false; rx_buf[0] = test_connection.getc(); test_connection.write(rx_buf, 1, 0, 0); }
int main() { wait(5.0); test_connection.attach(&serialCb);
test_connection.printf("hello\n"); while (0==0) { blink(); wait(1.0); } }
2 Answers
5 years, 1 month ago.
Please publish correct formatted code that users have a chance to understand what you are doing. The mbed code formatting will allow this. For Tags I recommand STM32L432, Serial
The the serialCb() you set “blinking = false; “ this may be the problem. Another point is I don’t know if the L432KC mbed clock setup allows 921600 baud, try a lower number e.g. 230400 which I verified that this works.
PS: For while (0==0) I usually use while(true) Regards Helmut
5 years, 1 month ago.
Interrupt serial definitely works on the L432KC, I'm using it, @ 921600 baud.
Try this simple program as an example and build your code round it.
https://os.mbed.com/users/sarahmarshy/code/SerialPassthrough/