Page 1 of 1

UART issues

Posted: Wed Sep 18, 2019 7:04 pm
by kcoelho
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

Re: UART issues

Posted: Wed Sep 18, 2019 9:49 pm
by jimmo
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?

Re: UART issues

Posted: Thu Sep 19, 2019 1:29 pm
by kcoelho
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

Re: UART issues

Posted: Thu Sep 19, 2019 2:10 pm
by jimmo
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.

Re: UART issues

Posted: Thu Sep 19, 2019 2:19 pm
by kcoelho
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?