summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-12-28 17:32:18 +1100
committerDamien George <damien.p.george@gmail.com>2016-12-28 17:32:18 +1100
commite81116d07d3fed43f77f81bd5e20800d9d798f5f (patch)
treeb99143d0328c67324ee67113ce204fb7945b5a1b
parent16a584d7cf7a46248ca308bdabb21a073d33ce80 (diff)
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).
-rw-r--r--stmhal/uart.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/stmhal/uart.c b/stmhal/uart.c
index 6582bda00..abe413bbf 100644
--- a/stmhal/uart.c
+++ b/stmhal/uart.c
@@ -623,8 +623,9 @@ STATIC mp_obj_t pyb_uart_init_helper(pyb_uart_obj_t *self, mp_uint_t n_args, con
// set timeout_char
// make sure it is at least as long as a whole character (13 bits to be safe)
+ // minimum value is 2ms because sys-tick has a resolution of only 1ms
self->timeout_char = args.timeout_char.u_int;
- uint32_t min_timeout_char = 13000 / init->BaudRate + 1;
+ uint32_t min_timeout_char = 13000 / init->BaudRate + 2;
if (self->timeout_char < min_timeout_char) {
self->timeout_char = min_timeout_char;
}