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;

0 REPLIES 0