cancel
Showing results for 
Search instead for 
Did you mean: 

L3GD20 gyroscope always returns 0 °/s – SPI working, WHO_AM_I = 0xD4

qw2
Associate

**Device**: STM32F429 + L3GD20 over SPI
**Toolchain**: STM32CubeIDE
**Driver**: Custom L3GD20 driver (HAL SPI-based)

---

**Issue**:
I am getting 0.00 °/s output from all three axes (X, Y, Z) continuously, even when I move the gyroscope.
WHO_AM_I register returns 0xD4 correctly. SPI read/write seems to work.

---

**What I Tried**:
- Wrote 0x0F to CTRL_REG1 (power on)
- Verified all wiring (MOSI, MISO, SCLK, CS)
- Read raw data registers: OUT_X_L/H, OUT_Y_L/H, OUT_Z_L/H → always zero
- Sensitivity used: 0.00875 for ±250 dps

---

**Code**:
```c
if (l3gd20_init(&hspi_5, GPIOC, GPIO_PIN_1) == L3GD20_OK) {
snprintf(msg, sizeof(msg), "l3gd20_initialized: who_am_i=0x%X\r\n", l3gd20_read_id());
}
l3gd20_read_raw(&raw_x, &raw_y, &raw_z);
float ang_rate_x = raw_x * 0.00875f;
float ang_rate_y = raw_y * 0.00875f;
float ang_rate_z = raw_z * 0.00875f;

1 REPLY 1
KDJEM.1
ST Employee

Hello @qw2;

 

Could you please check your custom L3GD20 driver by referring to stm32-l3gd20 driver and also to stm32f429i_discovery_gyroscope.c and to stm32f429i_discovery_gyroscope.h.

Also, I think BSP example in ST32CubeF4 firmware package under "STM32Cube\Repository\STM32Cube_FW_F4_V1.28.2\Projects\STM32F411E-Discovery\Examples\BSP" path can help you.

 

Thank you.

Kaouthar 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.