Closed philipphenkel closed 6 years ago
@finneyj @jaustin Can we get this fix into the next DAL release please? It affects all high level languages when they use the serial port, and causes a hard crash (display driver clearly stops updating the LED multiplex as the LEDs go bright)
@philipphenkel going through a review of open PRs here - do you mind sharing a few of your debug steps and how you determined this was the cause? We're trying to work out if there's a possible UART configuration option that fixes this more cleanly. This patch looks safe enough but want to make sure there aren't other cases to deal with too
@jaustin I worked on a package for MakeCode (pxt-makerbit) when I found out that the Microbit crashes always whenever serial data was received. Serial MP3 devices send data for example. I created a MakeCode program that just sends commands - without any read. The result is a crash because the call of serial redirect attaches to the RX interrupt and as a consequence the function that my PR fixes is called with high frequency forever.
My fix is supported by the mbed documentation of serial
Note: you need to actually read from the serial to clear the RX interrupt
In addition, we should consider to not always attach to the RX interrupt in case of a redirect.
I believe this issue is causing development issues for a new add-on we are designing for the Microbit.
Issue seems to be that when sending data with the add-on plugged in the microbit resets after a few packets are sent which is when the module replies back with an OK command which we ignore. To debug each stage I added a function to display on the microbit's display a number to indicate which line it was at. At a stage where it would then move onto the next step the display crashes and leaves only a few of the pixels of the stage it crashes at.
The same UART commands work fine in the latest beta of Micropython. The same code also works if I set the RX pin to one which is not connected.
Thanks @philipphenkel @ryanteck
Looks good to me.
I've merged this into the dal-integration branch for beta testing, which will go live with the next release, so closing off this issue.
@ryanteck - would be great if you could confirm that this fixes the issue you are seeing with your peripheral. Please do report back here of you do, and reopen this issue if you still see problems.
Seems to have fixed it, sorry about the delay in getting back. I'll report if I find any more issues @finneyj
excellent. Thanks for the quick feedback @ryanteck, certainly no apology necessary. :)
The Micro:bit crashes if the RX buffer is not initialized when data is received. The cause is that the RX interrupt is not cleared in this case.
This problem always appears after a redirect without any read operation.
Fixes https://github.com/Microsoft/pxt-microbit/issues/917 Potential fix for #152