machine.freq(value) hangs
Port, board and/or hardware
stm32 on WeActStudio.STM32H5_64Pin_CoreBoard
MicroPython version
MicroPython v1.23.0 on 2024-08-29; WEACT_H562RG with STM32H562RG
Reproduction
type on REPL
machine.freq(125000000)
Expected behaviour
MCU freq change to 125Mhz
Observed behaviour
REPL send invalid caracters until led blinks and MCU hangs
Additional Information
I've noted a lot of invalid entries on generated pllfreqtable.h that hangs the MCU
(1 << 24) | (0 << 16) | 100, << INVALID
(1 << 24) | (3 << 16) | 102, << INVALID
(1 << 24) | (2 << 16) | 104, << INVALID
(2 << 24) | (0 << 16) | 106, // M=2 N=53 P=2 Q=5 vco_in=4.00 vco_out=212.00 pll48=42.40
(1 << 24) | (1 << 16) | 108, << INVALID
(2 << 24) | (0 << 16) | 110, // M=2 N=55 P=2 Q=5 vco_in=4.00 vco_out=220.00 pll48=44.00
(1 << 24) | (2 << 16) | 112, << INVALID
(2 << 24) | (0 << 16) | 114, // M=2 N=57 P=2 Q=5 vco_in=4.00 vco_out=228.00 pll48=45.60
(1 << 24) | (0 << 16) | 116, << INVALID
(2 << 24) | (0 << 16) | 118, // M=2 N=59 P=2 Q=5 vco_in=4.00 vco_out=236.00 pll48=47.20
(1 << 24) | (0 << 16) | 120, << INVALID
(2 << 24) | (0 << 16) | 122, // M=2 N=61 P=2 Q=6 vco_in=4.00 vco_out=244.00 pll48=40.67
(1 << 24) | (0 << 16) | 124, << INVALID
(2 << 24) | (0 << 16) | 126, // M=2 N=63 P=2 Q=6 vco_in=4.00 vco_out=252.00 pll48=42.00
(1 << 24) | (2 << 16) | 128, << INVALID
(2 << 24) | (0 << 16) | 130, // M=2 N=65 P=2 Q=6 vco_in=4.00 vco_out=260.00 pll48=43.33
and solved the hang adding:
} else if (m == 1) {
// special entry for using HSE directly
if (sysclk == MICROPY_HW_CLK_VALUE){
sysclk_source = RCC_SYSCLKSOURCE_HSE;
}else{
continue;
}
to powerctrl.c and the freq changes to 122Mhz without hang. it would be better to fix the table but i'm not python expert to do it
Code of Conduct
Yes, I agree
16-bit SPI reads on STM32F413 - duplicated second byte
Port, board and/or hardware
stm32 port, NUCLEO-F413ZH board
MicroPython version
MicroPython v1.24.0-preview.449.g1b89c503d on 2024-10-20; NUCLEO-F413ZH with STM
32F413
Reproduction
Built with:
git clone git@github.com:micropython/micropython.git
cd micropython/ports/stm32
make BOARD=STM32F413ZH'
16-bit SPI reads work, with the same SPI device, on other platform(ESP32). On STM32 we observe two identical bytes, same as the 2nd one in normal operation
Expected behaviour
For reference, this is the same code (after initialization) run on ESP32
where it works like it should
MicroPython v1.23.0 on 2024-06-02; Generic ESP32 module with ESP32
Type "help()" for more information.
from machine import Pin, SPI
import struct, array
import binascii
spi=SPI(2)
spi.init(baudrate=1000000, polarity=0, phase=0, bits=16, firstbit=SPI.MSB, s
ck=Pin(18), miso=Pin(19), mosi=Pin(23))
cs = Pin(5, Pin.OUT, value=1)
bin = bytearray(2)
cs.off()
spi.write(struct.pack('>h', 0x5627))
spi.readinto(bin)
spi.readinto(bin)
binascii.hexlify(bin)
b'246a'
spi.write(struct.pack('>h', 0x5417))
spi.readinto(bin)
spi.readinto(bin)
binascii.hexlify(bin)
b'8f7b'
spi.write(struct.pack('>h', 0x5617))
spi.readinto(bin)
spi.readinto(bin)
binascii.hexlify(bin)
b'c840'
Observed behaviour
This is STM32 run. As we can see, the second byte of SPI.read is propagated
into the first one.
MicroPython v1.24.0-preview.449.g1b89c503d on 2024-10-20; NUCLEO-F413ZH with ST3
Type "help()" for more information.
from machine import Pin, SPI
import struct, array
import binascii
spi=SPI(2)
spi.init(baudrate=1000000, polarity=0, phase=0, bits=16, firstbit=SPI.MSB)
cs = Pin('B10', Pin.OUT, value=1)
miso = Pin('C2', Pin.AF_PP, pull=Pin.PULL_UP, af=Pin.AF5_SPI2)
mosi = Pin('B15', Pin.AF_PP, pull=Pin.PULL_UP, af=Pin.AF5_SPI2)
sck = Pin('B10', Pin.AF_PP, pull=Pin.PULL_UP, af=Pin.AF5_SPI2)cs.off()
bin = bytearray(2)
spi.write(struct.pack('>h', 0x5627))
spi.readinto(bin)
spi.readinto(bin)
binascii.hexlify(bin)
b'6a6a'
spi.write(struct.pack('>h', 0x5417))
spi.readinto(bin)
spi.readinto(bin)
binascii.hexlify(bin)
b'5151'
spi.write(struct.pack('>h', 0x5617))
spi.readinto(bin)
spi.readinto(bin)
binascii.hexlify(bin)
b'6a6a'
Additional Information
No, I've provided everything above.
Code of Conduct
Yes, I agree