2023-10-26 05:10 AM
Hi, Its my first post. Im trying a STM32L452 and IIS3dwb on SPI2 (SPI2_CLK on PB13). When I send the WHO_AM_I command, the SPI2_MOSI send only 0x0F instead 0x8F (0x0F OR 0x80). SPI2 setup is CPOL = High, CPHA = 2 Egde, 8 bits, MSB First, Baud Rate = 10MHz. PB1 is CS for IIS3DWB.
Acc = IIS3DWB_RegRead(IIS3DWB_WHO_AM_I);
unsigned char IIS3DWB_RegRead(unsigned char reg) {
unsigned char value = ((reg & 0x7F) | 0x80);
HAL_GPIO_WritePin(ACC_CS_GPIO_Port, ACC_CS_Pin, 0);
HAL_SPI_Transmit(&hspi2, &value, 1, 5000);
HAL_SPI_Receive(&hspi2, &value, 1, 5000);
HAL_GPIO_WritePin(ACC_CS_GPIO_Port, ACC_CS_Pin, 1);
return value;
}
Where am I going wrong?
Thanks!
2023-10-26 07:02 AM
That signal is definitely 0x8F.
2023-10-26 07:08 AM
I'm ashamed!
sorry
Thanks
2023-10-26 07:22 AM
> When I send the WHO_AM_I command, the SPI2_MOSI send only 0x0F instead 0x8F
Why do you think so? To me, this looks exactly like 0b10001111 = 0x8F (in SPI mode 3 as required by the sensor).
JW