My hardware only has one spi slave and one spi master. So can I just set the spi slave miso pin as output in spis_init function? If can not, can I set the pull down resistor on the slave miso pin on spis_init?
My hardware only has one spi slave and one spi master. So can I just set the spi slave miso pin as output in spis_init function? If can not, can I set the pull down resistor on the slave miso pin on spis_init?
I don't understand what you are trying to achieve by setting the SPIS miso pin as an output.
So do you mean I can set the intenal pull resistor on spis miso pin?
Yes, you can set the pull configuration in the PIN_CNF[x] register, but, are you sure that's what you want to do?
Yes, I just want to give the miso pin on slave side an const value. The new sdk set this pin pull on master side, but my spi master is an otp mcu. I think the pullup or pull down resistor will cost more power in spi transfer, so I want to set this pin as output.
I just want to give the miso pin on slave side an const value
But SPI requires a constant drive - either high or low - anyhow.
SPI is not open-drain.
Oh, right, the miso is already an output, you just need to set the pull configuration.
Use nrf_gpio_cfg:
dir = NRF_GPIO_PIN_DIR_OUTPUT
input = NRF_GPIO_PIN_INPUT_DISCONNECT
pull = NRF_GPIO_PIN_PULLDOWN
drive = NRF_GPIO_PIN_S0S1
sense = NRF_GPIO_PIN_NOSENSE
Oh, right, the miso is already an output, you just need to set the pull configuration.
Use nrf_gpio_cfg:
dir = NRF_GPIO_PIN_DIR_OUTPUT
input = NRF_GPIO_PIN_INPUT_DISCONNECT
pull = NRF_GPIO_PIN_PULLDOWN
drive = NRF_GPIO_PIN_S0S1
sense = NRF_GPIO_PIN_NOSENSE
the miso is already an output
So, surely, it will always be driving - either high or low ?
Therefore a pull up/down is pointless - it will just waste power and serve no useful purpose at all?
@haakonsh do you mean set as input and enable pull down?
the miso is already an output
And that output will always be driving either high or low - because that's what SPI requires.
SPI is not like I2C - where pullups are required because open-drain outputs are used.
Pull-up/down resistors serve no useful function in SPI - they purely waste power.
I agree with awneil, you do not need a pull resistor on an SPI line unless something is seriously wrong.
I do not know how I can be any more clear than:
dir = NRF_GPIO_PIN_DIR_OUTPUT
input = NRF_GPIO_PIN_INPUT_DISCONNECT
I do not know how I can be any more clear
Indeed.
cgha: again, look at the SPI Slave example in the SDK - it will show you how to correctly configure the nRF as an SPI Slave.