Hi, the PCB that was made in my project (PCB with a STM32F405 with some complements to use in other purposes), i have two UART's connected:
-UART3 in pins PB10 and PB11 (Y9, Y10)
-UART4 in pins PC10 and PC11 (SDIO_D2, SDIO_D3)
But after the PCB was made we notice the USART3 in PC10 and PC11 besides the dedicated pins to uSD. And now I'm stucked with that problem. Can I use the pins PC10 and PC11 in UART mode?
Using UART4 in PC10 and PC11 pins
Re: Using UART4 in PC10 and PC11 pins
Sorry I'm not quite sure what you're asking.joseaugusto07 wrote: ↑Wed Nov 25, 2020 6:24 pmBut after the PCB was made we notice the USART3 in PC10 and PC11 besides the dedicated pins to uSD. And now I'm stucked with that problem. Can I use the pins PC10 and PC11 in UART mode?
Yes, PC10 and PC11 can be set to alternate function for USART3 TX/RX, or for UART4 TX/RX.
-
- Posts: 4
- Joined: Fri Jul 17, 2020 6:40 pm
Re: Using UART4 in PC10 and PC11 pins
Ok, sorry if I don't explicited what I'm need. How can I set these pins to work with uart4 (in my script), I tried to initialize in "normal way" with pyb.UART(4,115200), but din't worked.
Re: Using UART4 in PC10 and PC11 pins
When you use then it will use the pins configured in the mpconfigboard.h file for your board.
For example, the pyboard is configured to use A0 and A1 for UART4: https://github.com/micropython/micropyt ... .h#L41-L42
If you want to use pins PC10/PC11 then you can either update mpconfigboard.h for your board and rebuild the firmware, or you can modify your script to fiddle with the AF stuff.
Code: Select all
pyb.UART(4,115200)
For example, the pyboard is configured to use A0 and A1 for UART4: https://github.com/micropython/micropyt ... .h#L41-L42
If you want to use pins PC10/PC11 then you can either update mpconfigboard.h for your board and rebuild the firmware, or you can modify your script to fiddle with the AF stuff.
-
- Posts: 4
- Joined: Fri Jul 17, 2020 6:40 pm
Re: Using UART4 in PC10 and PC11 pins
Sorry, I'm not experienced with rebuild firmwares in pyboard, can you help me with this? How can I start?
Re: Using UART4 in PC10 and PC11 pins
The README.md here: https://github.com/micropython/micropyt ... orts/stm32 (you need to scroll down past the file list to see it) has build instructions.
To change things in python, you'd do something like this:
To change things in python, you'd do something like this:
Code: Select all
uart = pyb.UART(4,115200)
# Switch A0/A1 back to GPIO inputs (after opening UART)
a0 = pyb.Pin('A0', mode = pyb.Pin.IN)
a1 = pyb.Pin('A0', mode = pyb.Pin.IN)
# Switch C10/C11 to be UART4
txPin = pyb.Pin('C10', mode=pyb.Pin.AF_PP, pull=pyb.Pin.PULL_NONE, af=pyb.Pin.AF8_UART4)
rxPin = pyb.Pin('C11', mode=pyb.Pin.AF_PP, pull=pyb.Pin.PULL_NONE, af=pyb.Pin.AF8_UART4)
-
- Posts: 4
- Joined: Fri Jul 17, 2020 6:40 pm
Re: Using UART4 in PC10 and PC11 pins
Thanks! I will use the python method for now (to continue the project) but I will try to rebuild firmware in in parallel.dhylands wrote: ↑Thu Nov 26, 2020 5:29 pmThe README.md here: https://github.com/micropython/micropyt ... orts/stm32 (you need to scroll down past the file list to see it) has build instructions.
To change things in python, you'd do something like this:Code: Select all
uart = pyb.UART(4,115200) # Switch A0/A1 back to GPIO inputs (after opening UART) a0 = pyb.Pin('A0', mode = pyb.Pin.IN) a1 = pyb.Pin('A0', mode = pyb.Pin.IN) # Switch C10/C11 to be UART4 txPin = pyb.Pin('C10', mode=pyb.Pin.AF_PP, pull=pyb.Pin.PULL_NONE, af=pyb.Pin.AF8_UART4) rxPin = pyb.Pin('C11', mode=pyb.Pin.AF_PP, pull=pyb.Pin.PULL_NONE, af=pyb.Pin.AF8_UART4)
Re: Using UART4 in PC10 and PC11 pins
I see a typo in my respone. I entered A0 twice when it should have been one for A0 and one for A1