Hello!
Does the SDK support a 3-wire SPI interface with bi-directional communication?
Like this:
Thanks!
Hello!
Does the SDK support a 3-wire SPI interface with bi-directional communication?
Like this:
Thanks!
Yes you can :-) This is a bare-metal example, but the same idea can be used with the Nordic drivers.
Start in 3-wire command transmit; Send the command, then configure for 3-wire receive:
// Send 3-wire whoami command byte (1 byte only) // Connect output drive, connect 1-wire rx/tx output to MOSI NRF_SPIM0->PSEL.MISO = 0xFFFFFFFF; // MISOPIN; NRF_SPIM0->PSEL.MOSI = MOSIPIN; NRF_GPIO->PIN_CNF[MOSIPIN] = 1; // output NRF_SPIM0->TXD.PTR = (uint32_t)spi3wTXBuf; NRF_SPIM0->TXD.MAXCNT = 1; NRF_SPIM0->RXD.PTR = NULL; NRF_SPIM0->RXD.MAXCNT = 0; NRF_SPIM0->EVENTS_ENDTX = 0; NRF_GPIO->OUTCLR = 1 << CSPIN; // drive cs low to initiate spi comm NRF_SPIM0->TASKS_START = 1; while(!NRF_SPIM0->EVENTS_ENDTX); // last byte transmitted // Manual says disable SPI before changing pins, but actually doesn't matter NRF_SPIM0->ENABLE = 0; // disable SPI // Disconnect output drive, connect 1-wire rx/tx input to MISO NRF_SPIM0->PSEL.MOSI = 0xFFFFFFFFUL; // MOSIPIN; NRF_GPIO->PIN_CNF[MOSIPIN] = 0; // input pin, input buffer connected, no pull, S0S1, sense disabled NRF_SPIM0->PSEL.MISO = MOSIPIN; // MISOPIN; NRF_SPIM0->ENABLE = 7; // enable SPI if it was disabled
This works fine; on some SPI devices remember the internal 3-wire register mode has to be set first before reading.
We rather not access the registers directly in our code, but thanks for the answer
We ended using the same SPI instance with different pins, we just need to enable/disable it every time we switch the device we are talking to
We rather not access the registers directly in our code, but thanks for the answer
We ended using the same SPI instance with different pins, we just need to enable/disable it every time we switch the device we are talking to
Hi! I've tried what you've mentioned here, and it works as far as enabling SPI communication.
We ended using the same SPI instance with different pins, we just need to enable/disable it every time we switch the device we are talking to
However, after configuring 2 SPI instances where one has MISO=PINX, MOSI unconnected, and the other has MISO= unconnected, MOSI=PINX, I see significant current leaks in all system modes (system on and system off).
I disable and uninit both SPI instances before entering low power mode.
Have you tested power consumption after using this solution? Have you modified your board in any way to accommodate this solution or was this strictly software?
Thanks!