Skip to content

Commit 6b1413d

Browse files
committed
Avoid losing input bytes in the UART on STM32F4xx.
The compiler expands an assignment to part of the DR register to a read-modify-write sequence. However, reading DR has the side-effect of clearing the SR.RXNE bit, so sending a byte could result in the loss of input bytes.
1 parent 983f3b1 commit 6b1413d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/ARM/STM32/drivers/uart_stm32f4/stm32-usarts.adb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ package body STM32.USARTs is
204204

205205
procedure Transmit (This : in out USART; Data : UInt9) is
206206
begin
207-
This.Periph.DR.DR := Data;
207+
This.Periph.DR := (DR => Data, others => 0);
208208
end Transmit;
209209

210210
---------

0 commit comments

Comments
 (0)