2016-11-25 05:56 AM
Hi,
We are using STM32F401 MCU, definition of SPI1 Initialisation function/api is attached, we need to make MOSI signal to be high (default it should be high), if no communation between master and slave.please suggest to how to make MOSI pin default high, if there is no communication between Master to slave.please need help.Thank you. #spi #stm32f42016-11-25 06:19 AM
MISO remains at the level of the last transmitted bit, and there's no option I know of which would change the SPI's behaviour in this.
Why do you need this? JW2016-11-25 11:30 PM
hi jan,
Thank you for quick reply. we have two setups: 1. working level setup (Atmel + VS1053b) 2. non working setup (STM32F401 + VS1053b) we observed the waveforms both cases, only difference we observed is MOSI signal is high(in setup 1) and low (in setup 2), whenever SPI idle case. so we assume there might be some issue with MOSI line, is there any issue with MOSI line low in setup 2?. please suggest.Thank you.2016-11-27 04:11 AM
I don't believe there is any SPI slave incarnation which would care about the idle level of input data line. Mind, SPI is just a minor evolution from a plain clock-edge-driven shift register.
I'd carefully check the captured waveforms against the VLSI chip's datasheet requirements as per data-to-clock-edge setup and hold times. JW2016-12-10 10:10 AM
What would happen with the following sequence:
- Enable SPI peripheral clock
- Write 0xFF in the DR
- Enable SPI register
Otherwise, you could also fake a transmit of a 0xFF data byte while the SPI MISO / MOSI pins are still Input with pull-ups and would get the job done with a little more effort.
Good luck!
2017-03-25 11:45 PM
Hi,
I am having the same problem. I use SPI in half duplex mode, and to make sure MOSI is never left floating, I have a pull-up (4K7) on that pin. Further more I have a series resistor (1K) to the slave device.
After the communication has completed, it would be nice, if the pin would always be high - to avoid any current drain via the pull-up resistor.
Is it just bad practice with that pull-up resistor?
I will try the suggested ways - to force the MOSI in a high state...
BR Martin
2017-03-26 04:45 AM
If MOSI is push pull, the current leak should be fine regardless of the level.
If there are specific reasons to have MOSI high when not communicating, you could switch SCK as input then transmit 0xFF... Pull-ups are mostly useful for input pins. For output pins it will create sinking current when MOSI is low.
2017-03-26 05:09 AM
Yes, it is possible to force the MOSI to high - if 0xFF is transmitted. It is not necessary to change SCK pin, because data can be transmitted without slave device is selected...
When using SPI in 3 wire mode (which is very typical when communicating with 3D sensors), the MOSI is automatically configured as inputs during communication, when slave transmits data. That is the reason, I have a pull-up on that pin.
BR Martin
2017-03-26 03:12 PM
Just put the device in slave mode when you're done? With NSS high, obviously.