Using Portenta H7 and Arduino and mbed - "uffff", how many features are missing?
Have you realized these issues, when you want to use Portenta H7 SPI (SPI2):
-
I cannot configure LSBFIRST. All comes out as MSBFIRST. Even there is a config flag in
// v NO EFFECT! SPI.beginTransaction(SPISettings(SPI_Frequency, LSBFIRST, SPI_Mode));
it does not do anything (still MSB first) -
When you try to configure SPI clock, it has just EIGHT dedicated values:
it is based on SPI peripheral divider (MBR), so 2, 4, 8, 16, 32, 64, 128 or 256 is used to divide your clock speed. Even the API takes a Hz value - it ends up just in 8 possible values (values are rounded down to next possible, e.g. 19 Mbps gives you 10 Mbps - "rrrrr"). -
When you change the MCU core clock, e.g. instead of 400 MHz you want to run with 480 MHz - it effects the SPI clock speed.
Obvious: mbed uses SYSCLK as SPI peripheral clock. Why not using PLL2 for it? -
SPI is just and only configured as SPI_DATASIZE_8BIT. Even I have a SPI device which is based on 32bit words - it is not supported. OK, it works, but the SPI bus shows me really SPI byte transactions (it could be 32bit words, instead), and it slows down a bit the speed at the end (gaps between bytes sent, not a smooth SCLK, at least not grouped in 32bit words).
-
I assume, the SPI runs in SW Polling Mode: no DMA used. A DMA would be nice to have a really smooth SCLK, a seamless transmission of all the bits (not this "broken" SCLK signal).
I could fix item 1 and 2. See attached source code.
It makes use of these "tricks":
-
go to SPI peripheral registers and write directly to configure LSBFIRST on device
-
change the clock source for SPI2 using PLL2 instead of SYSCLK
-
the use of PLL2 makes it independent of MCU core clock config and has the option to trim PLLN2 for a fine tuning of the SPI clock. In addition to SPI divider (MBR) for rough range, the PLL register is trimmed for intermediate values and fine tuning of SPI clock speeds.
Attached also the MCU core clock change to 480 MHz (why it is not default?)
Strange is: board schematics shows me a 27 MHz clock oscillator, but the config is based on assuming an external 25 MHz XTAL. Why?
Are the schematics wrong? Or am I running outside the spec. region with this config (even reading back SysClock tells me 480 MHz - but who knows what is assumed inside mbed API/FW...)
spi_if.h (715 Bytes)
spi_if.cpp (5.3 KB)
system_clock_override.cpp (11.6 KB)
Why Arduino does it make it so hard to use the boards, FW, mbed OS ...?
Why I have to spend most of my time to figure out the missing features, the not working stuff and to create a work-around?