Identity Crisis

SPI Sensor ID Reads Wrong Debug

Symptom

The bring-up log reads WHOAMI:0xD0. U2's datasheet gives its ID as 0x68. The registers and bit fields are on the Datasheet tab.

Circuit

Block diagram: U1, an STM32F4, drives U2, an SPI accelerometer, from SPI1 with chip select on PA4, SCK on PA5, MISO on PA6 and MOSI on PA7, and sends its log from USART1 TX on PA9 to a serial console

Pass condition

USART1 prints WHOAMI:0x and the ID in U2's register 0x75, as two upper-case hex digits, from one read in one CS frame.

Expected read on this board: one chip-select frame in which the master sends F5, register 0x75 with the read bit, then a dummy 00, while U2 answers FF then 68; the serial console then shows WHOAMI:0x68

Notes

The bench's U2 answers on SPI1 from power-up. The firmware asks U2 for its ID once, at boot.

U2's SPI timing from its datasheet: nCS falls to start a frame, SCLK idles low, U2 latches SDI on each rising SCLK edge and changes SDO after each falling edge, most significant bit first

Related challenges

Loading the interactive arena.