New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix UART BRR when OVERSAMPLING_8 #1276
Conversation
There was a bug in ST UART driver when OVERSAMPLING_8. At the moment micropython is only using OVERSAMPLING_16 so this bug is not affecting current micropython fw. But if one day one wants to enable higher baudrates (~5.5M to 10.5M) and use OVERSAMPLING_8 the bug is triggered (and e.g. setting 7M would give an actual 10.5M baudrate). This bug was revealed when playing around with the native firmware of hydrabus, see hydrabus/hydrafw#14 Source: STM32F405 reference manual, 30.3.4 page 965: USARTDIV is an unsigned fixed point number that is coded on the USART_BRR register. Note: • When OVER8=0, the fractional part is coded on 4 bits and programmed by the DIV_fraction[3:0] bits in the USART_BRR register • When OVER8=1, the fractional part is coded on 3 bits and programmed by the DIV_fraction[2:0] bits in the USART_BRR register, and bit DIV_fraction[3] must be kept cleared.
Did you try to report this to ST? |
I reported to a friend working at ST, will see if it's enough or if I need to go through some more official reporting |
There is a new version of the ST Cube HAL (1.5.0) which came out a month or so ago. Maybe it's fixed in that version? |
It doesn't appear to be fixed, although many things have been renamed and re-arranged. #define UART_DIV_SAMPLING8(_PCLK_, _BAUD_) (((_PCLK_)*25)/(2*(_BAUD_)))
#define UART_DIVMANT_SAMPLING8(_PCLK_, _BAUD_) (UART_DIV_SAMPLING8((_PCLK_), (_BAUD_))/100)
#define UART_DIVFRAQ_SAMPLING8(_PCLK_, _BAUD_) (((UART_DIV_SAMPLING8((_PCLK_), (_BAUD_)) - (UART_DIVMANT_SAMPLING8((_PCLK_), (_BAUD_)) * 100)) * 16 + 50) / 100)
#define UART_BRR_SAMPLING8(_PCLK_, _BAUD_) ((UART_DIVMANT_SAMPLING8((_PCLK_), (_BAUD_)) << 4)|(UART_DIVFRAQ_SAMPLING8((_PCLK_), (_BAUD_)) & 0x0F)) |
9167980
to
1cc81ed
Compare
This is fixed in the latest ST F4 HAL that this project is using. |
[ES] Translate strings on Mixer module
There was a bug in ST UART driver when OVERSAMPLING_8.
At the moment micropython is only using OVERSAMPLING_16 so this bug is not affecting current micropython fw.
But if one day one wants to enable higher baudrates (~5.5M to 10.5M) and use OVERSAMPLING_8 the bug is triggered (and e.g. setting 7M would give an actual 10.5M baudrate).
This bug was revealed when playing around with the native firmware of hydrabus, see hydrabus/hydrafw#14
Source:
STM32F405 reference manual, 30.3.4 page 965:
USARTDIV is an unsigned fixed point number that is coded on the USART_BRR register.
Note:
• When OVER8=0, the fractional part is coded on 4 bits and programmed by the DIV_fraction[3:0] bits in the USART_BRR register
• When OVER8=1, the fractional part is coded on 3 bits and programmed by the DIV_fraction[2:0] bits in the USART_BRR register, and bit DIV_fraction[3] must be kept cleared.