Thermometer

STM32 I2C Register Write Exercise

Task

The temperature sensor was left in shutdown, its reading frozen. Once after reset, wake it with 0x00 in its configuration register. The registers and bit fields are on the Datasheet tab.

Circuit

Block diagram: U1, an STM32F4, drives SCL on PB6 and SDA on PB7 to a bus with pull-ups R1 and R2 to 3V3; U2, a temperature sensor at address 0x48 whose configuration register 0x01 holds 0x01, shut down, sits on the bus, and TP1, a logic analyzer, records both wires

Pass condition

TP1 shows one write to the sensor at 0x48: 0x01, then 0x00, then a STOP. The bus is free when your program is done.

Expected on TP1: one write transaction, a START, the address 0x48 with the write bit, an ACK, the register 0x01, an ACK, the value 0x00, an ACK, then a STOP

Notes

The given code brings up I2C1, its clock included. Your program is built and run at -O0, then again at -O2. Both must pass.

Related challenges

Loading the interactive arena.