NRF52840, S140, SDK 14.2
I am trying to write to an SD Card. But whenever I insert the card, I get a failure on ASSERT. I believe this is because I am using P0.0 as the SCK pin, and anything &-ed with 0 is 0.
Does this mean I am not allowed to use the 0.0 SCK pin? That seems wrong. Was this fixed in a later SDK update?
When I comment out the && p_config->sck_pin, I no longer get the Assert. however, I get this error instead (triggered from nrf_drv_spi_init())
which is NRF_ERROR_INVALID_STATE (Invalid state, operation disallowed in this state)
I suspect this is because now that I am trying to use the SD Card, there are 2 SPI resources on the system. I configured the SD Card as follows:
Whereas the other SPI device was configured "normally":
(i do app_error_check in the fn that calls spi_config).
This error happens and the application freezes immediately when I use SPI 0 for the second SPI device. When I use SPI 1 for the second SPI device without changing the GPIO pins, I get strange behavior: my main loop stops running entirely (seems to hit power manage and just stop? but I have interrupts coming in), and garbage data (instead of the data that is normally sent) goes out on my SPI line to the second device. I am able to still connect over BLE though. Why is this happening?
I read this and this. My other questions:
- What SPI instance is the SD Card using? SPI 0?
- Is each SPI instance supposed to use its own separate GPIO?
If this is the case that I have to use a separate SPI instance with separate GPIO, it is a bit disappointing that NRF doesn't let you use SPI for its intended purpose (multiplexing data on a bus). I am a little low on board space and would prefer not to route 3 extra lines if possible. Please advise. What should my path forward be, to use SPI with SD card and a different device?
Thank you!