On the STM32 I can get code working to the console USB serial port, but is UART1 exposed through the M.2? I want to use it the same way I use the ESP32 micromod to send ExpressLink AT commands to the SARA R5 on the AT carrier board. I haven’t figured out how to setup the HardwareSerial or SoftwareSerial pins. Actually I’d like to use the STM32 with micropython but can’t figure out how to get machine.UART(1) working in micropython either. Any guidance?
This photo is low-quality for some reason (I’ll request a fix for that) but it looks like 17 & 19 https://cdn.sparkfun.com/r/600-600/asse … asheet.png on the micromod side, and the IC has these https://cdn.sparkfun.com/assets/8/a/a/7 … cessor.pdf (in case you want to directly access)
Here’s a spreadsheet of micromid pins https://cdn.sparkfun.com/assets/learn_t … Pinout.pdf and their descriptors https://cdn.sparkfun.com/assets/learn_t … ptions.pdf in case that’s handy
Finally there’s a UART example in our hookup guide https://learn.sparkfun.com/tutorials/mi … 8#examples
USART1 on the stm405 micromod board cannot be used, as the rx (and tx!) pins are both tied to 3.3v (and not even through a pullup). Why this was done is a mystery. See the schematic linked in previous post. The main micromod tx/rx serial pins are tied to the 405’s usart2, so you need to make that your main serial port.
The appropriate pin alternate-function init for usart2 needs to be done – I don’t know how that is targeted in micropython or arduino, as I don’t use those - I just use st’s standard periph library and gcc.
Thanks for the help. I guess I’ll need to go back to the ESP32 for now.
pbutler:
Thanks for the help. I guess I’ll need to go back to the ESP32 for now.
I was just recently working with Chris who did the SFE STM32 MicroMod definition for Micropython, and in addition to discovering some issues with I2C, I ran across a problem with the UART as well.
Here’s the PR where Chris is working on correcting the issue:
https://github.com/micropython/micropython/pull/8372
Anyway, to get a usable UART, you’ll need to modify mpconfigboard.h and change ‘UART1’ to ‘UART2’, as indicated below:
#define MICROPY_HW_UART2_TX (pin_A2)
#define MICROPY_HW_UART2_RX (pin_A3)
Build Micropython again, and you should be able to initialize the UART - the following shows reading incoming data from an Xbee radio:
MicroPython v1.18-212-geec07332b-dirty on 2022-03-16; SparkFun STM32 MicroMod Processor with STM32F405RG
Type "help()" for more information.
>>> from machine import UART
>>> uart = UART(2, 115200)
>>> uart.readline()
b'Data received from 0013A2004195C773 >> testing SFE\r\n'