2022-03-12 05:18 PM
Can someone please tell me the sequence and list of registers / bits I need to touch to get this device into 3 wire SPI mode?....I am monitoring it on a logic analyzer and continue to see the data from the device on the MISO line....
I am running at 4MHz and am set to CPOL = 1, CPHA = 1 (mode 3). I can write to the WHO_AM_I and get back the correct value 0x69 on the MISO line.....BUT I need to operate this in 3 wire mode (ie data returned to CPU on MOSI).
The sequence (or where I am at now is):
WReg 0x12
WValue 0x08 (turn SPI 3 wire on, disable auto increment address)
WReg 0x13
WValue 0x04 (disable I2C enable SPI)
RReg 0x0F | 0x80
send 0x00 (produces clocks)
data on MOSI but now it reads 0x41???
BTW....I switched register 12 and 13 above and it didn't make a difference
Thanks
2022-03-12 11:59 PM
My checklist:
1. Short miso amd mosi of STM32 on the board
2. Check if the mems need to be written a bit to activate 3 wire mode. If yes, write it.
3. To read, disable MOSI in bidirectional mode
The challenge is to make sure mosi is disable when the sensor is sending out data. You can dynamically play with the gpio MODER register by hacking.
On some STM32, except bidir mode, you can't control the spi clock generation all the time.
2022-03-13 11:13 AM
To your points above:
I found the bit in the mems and am able to read back the WHO_AM_I. What do you mean disable MOSI.....I have set up the STM32L476 in CubeMX and have set it to 'Master Half Duplex'. In my setup code (before while loop) I write to the mems device firstly to turn it into 3 wire mode. Am I missing something here in disabling MOSI???