cancel
Showing results for 
Search instead for 
Did you mean: 

3-Wire SPI to demo board not working?

SWenn.1
Senior III

Good afternoon.

I have configured SPI2 on STM32L476RG as Master Half Duplex, clock = 4MHz, CPOL = 1, CPHA = Edge 2. I am connected to a Pololu 2736 demo board (LSM6DS33). The timing diagram for the part shows resting clock as high (CPOL = 1) and MISO being clocked in on falling edge (CPHA - Edge 2). I have verified:

  1. Power at the component is good.
  2. Signals on logic analyzer look good.

My while loop code looks like the following as I am just trying to read the WHO_AM_I register:

	  HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_RESET);
	  txBuf[0] = 0x0F;// | 0x80;
	  txBuf[1] = 0;
	  HAL_SPI_Transmit(&hspi2, txBuf, 2, 50);
	  HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET);
	  HAL_Delay(20);

0693W00000KcO0QQAV.pngI always receive 0x00 back. I have tried spacing out the register transmission with the dummy clock transmission (for reading) by 1ms as well and see no difference. Can anyone give my an idea as to what I have missed?????? I have gone as far as also writing to the CTRX1 register to enable the accelerometer out of low power mode before the read just in case it had something to do with that and it still didn't work......

Please don't refer me to the driver files on github as I am a hardware guy and at the moment that just complicates my already weak firmware background.

I've posted here rather than the sensor group bcz I figured it is more FW than HW given I am using a Nucleo working board and a new LSM6 demo board

Thank you.

1 REPLY 1
SWenn.1
Senior III

UPDATE:

If I change to 0x8F and 4 wire SPI I see the MISO line putting out 0x69 (the correct value)....But how can I get this to show up on the MOSI line in 3 Wire mode (Master Half Duplex )???