Skip to content

Commit

Permalink
Avoid losing input bytes in the UART on STM32F4xx.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
reznikmm committed Jan 27, 2025
1 parent 983f3b1 commit 6b1413d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/ARM/STM32/drivers/uart_stm32f4/stm32-usarts.adb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ package body STM32.USARTs is

procedure Transmit (This : in out USART; Data : UInt9) is
begin
This.Periph.DR.DR := Data;
This.Periph.DR := (DR => Data, others => 0);
end Transmit;

---------
Expand Down

0 comments on commit 6b1413d

Please sign in to comment.