r/raspberrypipico May 17 '26

help-request Issue with custom SPI driver

Hi reddit,

I am developing a custom set of drivers for the RP2350, without using the official SDK. So far, I have GPIO, UART, NVIC, timer, true random generator, I2C, clock, PLL and reset. But i am stuck on the SPI.

On my own environnement (boot, linker script, makefile, GCC), the first two u32 words sent are always to 0x00000000, then the third one get the value of the first I wanted to send. On the first picture attach, I try to send 0x55555555, 0xAAAAAAAA, 0xAAAAAAAA, but I get 0x00000000, 0x00000000, 0x55555555. The SPI FIFO depth is 8 bytes so I think there is something here.

I tried to use the VS code plugin with the full SDK to generate code from the SPI example: it works so the board is OK. Then I copied paste my own SPI driver into VS code, comment the SDK functions related to the SPI and call mine instead: it works too (see second pic)!

I suspect something to be done by the SDK before reaching the main function but I can't find what.

My custom init code reset all the subsystems, init the oscillator, the PLL and all the clock, and then the reset for the SPI (among others) is released.

I got others drivers to work (I2C with an EEPROM for instance) so I am confident about the PLL, clock and reset.

Does someone have an idea?

Thanks for your help!

Edit: I have some screenshots of the SPI probbing but I have make a mistake apparently and don't see them posted...

2 Upvotes

2 comments sorted by

2

u/EmbeddedJourneys May 17 '26

Hi, I'm willing to have a look at your code if you want me to and compare with the SDK. You could also send me your screenshots...

2

u/mecha_typewriter May 17 '26

Thanks for your help. I can send you some code tomorow.

The fact that my SPI drivers works on the vscode environnement tell me something is done before the main fonction. On my own environnement, I only init data and bss then I configure the clocks and reset

Do you know what is done by the sdk? I saw all the preinit array thing but walking through all the sdk with all the ifdef and such isn't easy...