This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SPI overwrite by GPIO input

Hello .

We have an issue with the SPI channel.

We found out that when our GPIO config as SPI the CS drawn a lot of current when it connect to the slave device device AD7770. It is most problematic when we want to be on lowest current when no communicate with this device. Because we can't make any change in the board we want to configure the CS as input and change back to SPI when we need the communication.

But after config CS as input nathing make it back to SPI (remember I didn't uninit it), unless I uninit it and make again the whole setting of SPI init. I try gpio disconnect, I try SPI->ENABLE go to "0" and then back to "1" .

Is there a quick method, to go between GPIO input to SPI on the some pins?

Thanks for the answers

Bar. 

  • Not sure how the CS pin is drawing current, can it be that VDD to AD7770 is cut, and you are sourcing current through the CS pin to the AD7770? If you have an unused GPIO I assume you could just disable SPIM, reconfigure PSEL.CSN to unused pin, configure GPIO, and enable SPIM again. 

    Kenneth

  • Hi Kenneth. I found the reason for the current. The AD7770 with no power make a path threw the protecting diode from CS "1" to VDD "0". So I need an input. I try to make the SPI disable then the SEL.CS disconnect (there isn't unused in the SPI config). and then config that pin to GPIO input. But when I need again the SPI to active I need to reconfig it as in SPI_init. and for that I need first uninit to that SPI.

    Bar.

  • How about using one of the SPIM instances that don't have hardware support for CSN (e.g 0-2), then you can configure/use the CSN pin as you see fit at any time. Just set CSN pin to NRFX_SPIM_PIN_NOT_USED during init of SPIM (then the driver will not use the CSN pin at all). Then you can from the application set CSN as any GPIO as you wish at any time, though you likely want to set it low before you start spi transfer, and clear it afterwards.

Related