Open microbit-sam opened 5 years ago
Carlos from other ticket
From our fork of Mbed: https://github.com/lancaster-university/mbed-classic/blob/3d3ff2e7eb9e25edac1dc0784193e440d86aeda6/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/serial_api.c#L76-L78
void serial_init(serial_t *obj, PinName tx, PinName rx) {
...
// dummy write needed or TXDRDY trails write rather than leads write.
// pins are disconnected so nothing is physically transmitted on the wire
obj->uart->TXD = 0;
And from upstream MbedOS the feature has been upgraded to be more robust! https://github.com/ARMmbed/mbed-os/blob/646cc89a620f978ed6174cb7bbb921e0f0d910f2/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/serial_api.c#L79-L84
void serial_init(serial_t *obj, PinName tx, PinName rx) {
...
// dummy write needed or TXDRDY trails write rather than leads write.
// pins are disconnected so nothing is physically transmitted on the wire
obj->uart->PSELTXD = 0xFFFFFFFF;
obj->uart->EVENTS_TXDRDY = 0;
obj->uart->TXD = 0;
while (obj->uart->EVENTS_TXDRDY != 1);
The interesting part is the comment that says pins are disconnected so nothing is physically transmitted on the wire
, perhaps we are configuring the pins before the init function does it, or maybe the comment is not correct anymore. We need to compare the entire function from MbedOS as perhaps sending the byte on the wire was a bug.
Bug Description
When the serial interface is initialised some garbage data is sent out
This is probably to do with the mbed serial driver as a similar problem is described here: https://github.com/bbcmicrobit/micropython/issues/472#issuecomment-334364423
How To Reproduce
Expected behavior
The initial packet should not be sent