UART issues

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
kcoelho
Posts: 23
Joined: Fri Aug 02, 2019 5:40 pm

UART issues

Post by kcoelho » Wed Sep 18, 2019 7:04 pm

Hello,

I have a custom port for the stm32f437 MCU and I have been trying to get UART7 and UART8 working but I cannot get it working.

I have added the definitions to the mpconfigboard.h

#define MICROPY_HW_UART7_TX (pin_E8)
#define MICROPY_HW_UART7_RX (pin_E7)
#define MICROPY_HW_UART8_TX (pin_E1)
#define MICROPY_HW_UART8_RX (pin_E0)

However, I get the error that the UART(7) or UART(8) doesn't exist

I additionally sometime get the error:

ValueError: set baudrate 0 is not within 5% of desired value

What else am I not doing?

Would appreciate the help

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: UART issues

Post by jimmo » Wed Sep 18, 2019 9:49 pm

hi,

If you grep the codebase for where (for example) MICROPY_HW_UART6_TX gets used and you'll see the code that actually uses these macros.

What baud rate are you setting it to when you get that error?

kcoelho
Posts: 23
Joined: Fri Aug 02, 2019 5:40 pm

Re: UART issues

Post by kcoelho » Thu Sep 19, 2019 1:29 pm

jimmo wrote:
Wed Sep 18, 2019 9:49 pm
hi,

If you grep the codebase for where (for example) MICROPY_HW_UART6_TX gets used and you'll see the code that actually uses these macros.

What baud rate are you setting it to when you get that error?
I'm setting it to 9600

And that macro only seems to be used in uart.c in the /stm32 directory

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: UART issues

Post by jimmo » Thu Sep 19, 2019 2:10 pm

kcoelho wrote:
Thu Sep 19, 2019 1:29 pm
And that macro only seems to be used in uart.c in the /stm32 directory
Yes, everything in the machine is implemented per-port (with some common code extractes out for things like SPI and I2C)

But yes, uart.c uses those macros to map the uart number passed to the constructor, so you'll need to add the equivalent for 7 and 8.

kcoelho
Posts: 23
Joined: Fri Aug 02, 2019 5:40 pm

Re: UART issues

Post by kcoelho » Thu Sep 19, 2019 2:19 pm

jimmo wrote:
Thu Sep 19, 2019 2:10 pm
kcoelho wrote:
Thu Sep 19, 2019 1:29 pm
And that macro only seems to be used in uart.c in the /stm32 directory
Yes, everything in the machine is implemented per-port (with some common code extractes out for things like SPI and I2C)

But yes, uart.c uses those macros to map the uart number passed to the constructor, so you'll need to add the equivalent for 7 and 8.
Thanks for responding so soon.

It seems to be even weirder now. I am getting the following error in the REPL prompt:

test = UART(8,9600)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: set baudrate 19200 is not within 5% of desired value

Not sure how this is happening happens?

Post Reply