Interfacing the LM75BD [temperature sensor] on a Zynq board with the name “Z-turn”.
The temperature sensor, on board, is LM75B (NXP link):
It’s an 11-bit ADC (with increments of 0.125°C)
The 7-bit [I2C] address (taken from the previous picture) is 0x49.
It is connected to I2C0, which is connected to PL pins P15 & P16. The provided contraints file has been set up.
For those new to Zynq, some pins are accessed through the PS part while others through the PL. (Pins of the former, have names like MIO51. This is what makes Zynq special, splitting the workload between the hard processor and the programmable logic).
Even though it’s possible to handle I2C entirely in the PL (excluding the PS), we’ll stick with using the PS’s native, embedded I2C controller.
Accordingly, the library that’ll be used is the I2C-PS, with the respective API.
(Ideas will be taken from the xiicps_polled_master example).
The sensor’s [temperature] register, is at address 00h.
(All code has been provided). The following sums up the PS part:
Initialization:
XIicPs_LookupConfig(XIICPS_BASEADDRESS);
XIicPs_CfgInitialize(&Iic, ConfigPtr, ConfigPtr->BaseAddress);
XIicPs_SelfTest(&Iic);
XIicPs_SetSClk(&Iic, IIC_SCLK_RATE);
Reading temperature:
XIicPs_BusIsBusy(&Iic)
XIicPs_MasterSendPolled(&Iic, const_cast<uint8_t*>(v.data()), v.size(), SLAVE_ADDRESS); // Send register address (00h)
XIicPs_BusIsBusy(&Iic)
XIicPs_MasterRecvPolled(&Iic, result.data(), result.capacity(), SLAVE_ADDRESS); // Read register's (00h) value