7 years, 6 months ago.

Possible bug in Serial attach() function with mbed 2.0 Rev 125

I think mbed 2.0 Rev 125 introduced a bug in the attach() function of the Serial class for the NUCLEO-F303K8 target. The attach() function behaves as expected for the NUCLEO-F303K8 using mbed 2.0 Rev 124 .

The same bug also seems to appear in all versions of the mbed 2.0 for the NUCLEO-L432KC target, which was first released in Rev 122.

My application uses Serial1 to read packet data from the serial output of an r/c receiver using interrupts. It uses the default Serial2 as a monitor. For safety and other reasons, the r/c transmitter is typically powered up and transmitting data prior to powering up the r/c receiver. This means that I want to be able to initialize the NUCLEO’s Serial1 and attach the interrupt with serial data present at the Rx pin of Serial1.

The function call I am using is:

rx.attach(&rx_callback,Serial::RxIrq);

My NUCLEO-F303K8 and NUCLEO-L432KC both behave as expected using mbed 2.0 Rev 125 with no data present at the Rx pin of Serial1 when the attach() function is called. The code runs and interrupts are correctly generated if I turn on the r/c transmitter to present data at the Serial1 Rx pin AFTER the interrupt has been attached.

Using mbed 2.0 Rev 125, both NUCLEO targets hang up when the attach() function is called if there is data present at the Rx pin of Serial1 when the attach() function is called.

Fortunately, NUCLEO-F303K8 works as expected using mbed 2.0 Rev 124 even if there is data present at the Rx pin of Serial1 when the attach() function is called. This makes me think that there was a change in Rev 125 that interferes with the attach() function - at least the way I am using it.

Note that I also tried RawSerial using mbed 2.0 Rev 125, but I did not see a difference in behavior.

Is there a simple workaround that will allow me to attach an interrupt to a Serial peripheral while there is data present at the Rx pin?

There should be no difference whether serial data is present. I think somehow you've exposed a bug in your algorithm. Can you post up some simple code to investigate the problem with? I suspect somehow the interrupt handler is getting called constantly and you need to service the data to clear the interrupt.

posted by Bill Bellis 11 Sep 2016

I filed a bug report here: https://github.com/ARMmbed/mbed-os/issues/2670/...

posted by Jan Jongboom 12 Sep 2016

4 Answers

6 years, 9 months ago.

Hey - sorry for not supporting earlier ... but is the problem still visible on recent MBED versions ? I tried to reproduce here with MBED2 Serial interrupt test (PC sends data to target ..) and could not reproduce. If you have sample code I can try again

Accepted Answer

I am using mbed "classic" with the online compiler. Version 145 appears to have fixed the problem I was having with my L432KC boards. I still experienced the problem with Version 144, so the Version 145 update seems to have resolved it.

posted by J Roth 05 Jul 2017
7 years, 6 months ago.

No issues here on rev 125 running on ST F446RE Nucleo

Thanks. Based on your response I tried loading the exact same code onto other NUCLEO boards that I have. Here is a summary of the behavior for 5 different platforms using the exact same code:

- Works as expected using Rev 125 with my NUCLEO-F103RB and NUCLEO-F401RE. - Works as expected using Rev 124 with my NUCLEO-F303RE and NUCLEO-F303K8 - Hangs up at the attach() function call using Rev 125 with my NUCLEO-F303RE and NUCLEO-F303K8 if there is data present at the Rx pin, but works fine if no data is present at the RX pin at the time the attach() function is called. - Hangs up at the attach() function call using any mbed version with my NUCLEO-L432KC if there is data present at the Rx pin, but works fine if no data is present at the RX pin at the time the attach() function is called.

I hope this additional information helps.

posted by J Roth 11 Sep 2016
7 years, 6 months ago.

I have also problems on Nucleo 411RE with the serial interface. The Version 122 works fine. Version 124 has also the same bug behaviour like version 125, The Nucleo hangs, when I send data over the serial line. I was not able to investigate this in deep. Therfore I use version 122 at the moment.

https://developer.mbed.org/forum/bugs-suggestions/topic/26716/

7 years, 6 months ago.

I'm having issues too with the NUCLEO-F303K8, I was trying to receive a communication with Serial2 but the board was receiving nothing, then I found this question and went back to change the revision, now the board is working with release 121, can't figure why the newer releases are not working properly :/.

Hmmm looks like v125 did indeed change the serial driver for these boards mentioned. https://developer.mbed.org/teams/ST/wiki/SDK-changes-log#v125-16w35

posted by Bill Bellis 12 Sep 2016

Changes in version 124:

DISCO_F429ZI/F469NI, NUCLEO_F410RB/F411RE/F429ZI/F446RE Add Serial Flow Control pins

F411RE is the board I have. And I have problems with v124 also.

posted by Roland Deschain 12 Sep 2016

Looks like this is still an issue... At least with Serial 2 on L432KC and F303K8 boards.

posted by Andrew Wakestrap 16 Apr 2017