I'm trying to make some driver code to talk to a flash chip via SPI. I'm using the nrf5340 and SDK 2.0.0. I'm also doing this for the secure board environment the DK app, not the DK app_NS.
The simple SPI transceive that seems to work is:
And if you spend the time to really look.
spi_cs.gpio_dev is deprecated but SPI doesn't work without it, so if anyone knows what to do about this, I'd love to know.
But the .len items in both structs is the size of the arrays. So when I call spi_transceive I can see on the logic analyzer that 1024 bytes get clocked out. That works fine.
I'm trying to read 768 bytes out of my flash chip, so I called a function (and I did this loop to find out where it fails.
I have this struct and function
I know that's a lot of code to look through. But it's not really doing anything too crazy.
The problem is when want to get 510 bytes from SPI (and it adds in 4 header bytes, 1 command and 3 address) for a total of 514 bytes of communication, it works fine. But if I call:
where x = 511, for a total of 515 bytes of SPI transmission. The whole thing crashes. I can debug through
and all the way down to
I can debug to here
Then if I step into the spi_transceive() function
it goes to here
Then here
and then one more step it jumps back out to the beginning of my init code, with no SPI output.
How do I debug this. I get no information or why it's moving to this point in the code. It's basically the first breakpoint that I put in the code that gets hit when I was debugging. Goes from SPI transceiver right to the first breakpoint I set. I don't know if it's crashing, or rebooting. And it's not like there is any allocated memory. If I make the loop go from 1 byte of data to 768 bytes, it will transmit over SPI 1 byte, then 2, then 3,.... etc to 510 and then when I hit 511 it crashes. If I'm not debugging my whole application reboots and starts over.
I saw someone say to try putting this in my prj.conf file
but it still reboots.
Anyone know how to debug some code that just reboots and doesn't give any idea as to why?