6 years, 9 months ago.

NUCLEO-F103RB hangs on Serial RX interrupt

I tried a very simple code on NUCLEO-F103RB board and found a strange behavior.

When I use "Serial" and attach a function by Serial.attach(), the code freezes after receiving an incoming serial message. Nothing inside the Rx callback seems to be executed. (The code does not use RTOS.)

main.c (It does not work.)

#include "mbed.h"

Serial pc(USBTX, USBRX, 9600);
void rxCallback() {
    pc.putc(pc.getc());
}
int main() {
    pc.attach(&rxCallback , Serial::RxIrq);
    while(1) {
        // Do nothing
    }
}

However, it works well when I use RawSerial instead of Serial.

main.c (It works!)

#include "mbed.h"

RawSerial pc(USBTX, USBRX, 9600);
void rxCallback() {
    pc.putc(pc.getc());
}
int main() {
    pc.attach(&rxCallback , RawSerial::RxIrq);
    while(1) {
        // Do nothing
    }
}

This problem seems to be specific to NUCLEO-F103RB board because it doesn't happen on FRDM-KL25Z or LPC11U24.

Do you know any solution for it?

Hello Mariko,
I have tried the code you published on my NUCLEO-F103RB with the latest mbed (OS 2) and it seems to work well. At least I was not able to reproduce the reported problem. For testing I used "Termite 3.3" as serial terminal running on my PC.

posted by Zoltan Hudak 14 Jul 2017
Be the first to answer this question.