Skip to content

Commit e81116d

Browse files
committed
stmhal/uart: Increase inter-character timeout by 1ms.
Sys-tick resolution is 1ms and a value of 2 will give a delay between 1ms and 2ms (whereas a value of 1 gives a delay between 0ms and 1ms, which is too short).
1 parent 16a584d commit e81116d

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

stmhal/uart.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,9 @@ STATIC mp_obj_t pyb_uart_init_helper(pyb_uart_obj_t *self, mp_uint_t n_args, con
623623

624624
// set timeout_char
625625
// make sure it is at least as long as a whole character (13 bits to be safe)
626+
// minimum value is 2ms because sys-tick has a resolution of only 1ms
626627
self->timeout_char = args.timeout_char.u_int;
627-
uint32_t min_timeout_char = 13000 / init->BaudRate + 1;
628+
uint32_t min_timeout_char = 13000 / init->BaudRate + 2;
628629
if (self->timeout_char < min_timeout_char) {
629630
self->timeout_char = min_timeout_char;
630631
}

0 commit comments

Comments
 (0)