MOSI not doing anything on pi pico on bare metal (no sdk)
I am trying to set up SPI to use a SD card module with my pi pico, but no matter what i do it seems like the mosi pin does nothing, the internal loopback works fine but not if i physically bridge the pins.
17 Replies
Why no SDK, no Arduino framework? Is this for a school assignment?
is there a problem with me doing it this way? i just thought this would be an interesting project
We're not allowed to help with school assignments. The most common reason for someone approaching a task this way is because they were required to for a school assignment.
Have you looked at the SDK or Arduino framework's source code for SPI?
That could be helpful.
it's not a school assignment, i just wanted to do something to pass time
so far its been working since overall ive been working on this for a week, and 4 days trying to get spi working
i have cross referenced with the sdk, another spi implementation, and even a sd card library
i havent found any other mention of my problem online, and i find it weird that the internal loopback works, but not normal, even though i set the pin as output
Is the loopback test your only method of verifying whether or not it's working?
Can you post the code here?
i tried using another MCU and a sd card module aswell. The mcu confirmed that it was making transfers, but no data was actually transferred. It's 2:32 am for me, but I'll post the code here tomorrow when i can.
here is my initialization function
and here is my rw function
i also have variations that only write or read
i also have this for my SD card initialization function if it helps, but im pretty sure the problem isnt here
the "str" is a leftover from some debugging
i have also added a pullup resistor to MISO since it kept floating with the sd card module
Where do these definitions come from?
PADS_BANK0_GPIO09
i dont have registers set up as structs yet, but its jusdt the pads base + gpio9 offset
This is in your code somewhere? Can you post the whole thing?
i can post the c file with most stuff, it doesnt have clock initialization, but i do switch the peripheral clock to XOSC there
please ignore how messy it is, i thought that SPI wouldnt be much of a hurdle and was putting off cleaning it up after it
This is a lot to look at. Won't have time until later. One question just glancing at it, for example, Is there a definition in the pico SDK that you would consider equivalent to
PADS_BANK0_GPIO09
?the sdk has structs defined for everything, i'd have to go over it again but im pretty sure there was one iirc
also that is my software CS pin, which appears to work fine
i wanna get it working before i clean up, so i dont accidentally break something in the process
No GPIO is selected for MISO? Should be GPIO8.
MISO is the pin i actually confirmed works
since tying it to 3.3v makes it read 0xFF
i've also tried the pico SDK "default" configuration, but still miso seems to work but not mosi
while testing with a LED, ive noticed that SCK might also not be doing anything
which the test with another mcu confirms
i set up the chip select pin the same way i do the rest, and it works fine
its 2 am, but i have discovered, that it works on the default pin configuration
even though the one i was using before should have been supported
i cant resolder the pin headers atm since its so late, but ill test with another mcu tommorow
ive seen someone on reddit describe a similar issue, where they couldnt get MOSI working on GP2 or 3
Im so close, i can tie the pins together physically, and get a loopback, but trying with another MCU, it sees the transfers now, but its all 0x00
i set it to transmit 0xFF in a loop atm
Sorry, I thought you had it working here https://discord.com/channels/420594746990526466/1390110941890351155/1390483048880930926
Is it just using different pins that isn't working now?
no, using different pins made it work, but i seem to have a problem with reading now
im testing with another mcu, which should loop back all the 0xFF, but im getting more 0x00 with 0x0FF at seemingly set offsets
the original issue is solved, its probably my code that is faulty now
i tweaked it a bit, but something is still weird since it seems like im sending 4 bytes of nothing at the end of my transmission
this could very well also be a bug in my slave loopback code
ill try initializing a SD card and see if it works
im pretty sure it works, i can get the SD card to respond with0x01 to CMD0!
i think the issue can be marked as solved