iic
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
xiic_pmbus_polled_example.c File Reference

Overview

Shows polled PMBus transfers over IIC.

This file consists of a polled mode design example which uses the Xilinx IIC device and low-level driver to communicate with a PMBus device.

The example demonstrates how to read voltage and temperature from a PMBus-compliant device using the IIC interface. It includes conversion routines for PMBus Linear11 and Linear16 formats.

The XIic_Send() API is used to transmit the data and XIic_Recv() API is used to receive the data.

The define PMBUS_SLAVE_ADDR in this file needs to be changed depending on the PMBus device and board configuration on which this example is to be run.

This code assumes that no Operating System is being used.

MODIFICATION HISTORY:
Ver   Who  Date        Changes


3.15 vlt 02/18/26 Initial version 3.16 tb 09/22/26 Align Doxygen comments with AMD documentation standards

#include "xparameters.h"
#include "xiic.h"
#include "xiic_l.h"
#include "xil_printf.h"
#include "xil_types.h"

Macros

#define XIIC_BASEADDRESS   XPAR_XIIC_0_BASEADDR
 Base address of the IIC device. More...
 
#define IIC_MUX_ADDRESS   0x75
 7-bit IIC MUX address. More...
 
#define IIC_PMBUS_CHANNEL   0x04
 IIC MUX channel for PMBus. More...
 
#define PMBUS_SLAVE_ADDR   0x0A
 7-bit PMBus slave address. More...
 
#define IIC_MUX_ENABLE
 Enable IIC MUX on boards that use one. More...
 
#define PMBUS_CMD_READ_VOUT   0x8B
 Command to read output voltage (VOUT). More...
 
#define PMBUS_CMD_READ_TEMP   0x8D
 Command to read temperature (TEMP). More...
 
#define PMBUS_VOUT_EXPONENT   (-12)
 Exponent used in the calculation of vout voltage. More...
 
#define EXPONENT_SHIFT   11
 Shift to get exponent bits. More...
 
#define EXPONENT_MASK   0x1F
 Mask for 5-bit exponent. More...
 
#define MANTISSA_MASK   0x7FF
 Mask for 11-bit mantissa. More...
 
#define EXP_SIGN_BIT   0x10
 Exponent sign bit. More...
 
#define MANT_SIGN_BIT   0x400
 Mantissa sign bit. More...
 

Functions

int IicPmbusPolledExample (void)
 Demonstrates PMBus access in polled mode. More...
 
int main (void)
 Runs the PMBus polled example. More...
 

Variables

XIic IicInstance
 The instance of the IIC device. More...
 
u8 ReadBuffer [2]
 Buffer used to store data read from the PMBus device. More...
 

Macro Definition Documentation

#define EXP_SIGN_BIT   0x10

Exponent sign bit.

#define EXPONENT_MASK   0x1F

Mask for 5-bit exponent.

#define EXPONENT_SHIFT   11

Shift to get exponent bits.

#define IIC_MUX_ADDRESS   0x75

7-bit IIC MUX address.

#define IIC_MUX_ENABLE

Enable IIC MUX on boards that use one.

#define IIC_PMBUS_CHANNEL   0x04

IIC MUX channel for PMBus.

#define MANT_SIGN_BIT   0x400

Mantissa sign bit.

#define MANTISSA_MASK   0x7FF

Mask for 11-bit mantissa.

#define PMBUS_CMD_READ_TEMP   0x8D

Command to read temperature (TEMP).

Referenced by IicPmbusPolledExample().

#define PMBUS_CMD_READ_VOUT   0x8B

Command to read output voltage (VOUT).

Referenced by IicPmbusPolledExample().

#define PMBUS_SLAVE_ADDR   0x0A

7-bit PMBus slave address.

#define PMBUS_VOUT_EXPONENT   (-12)

Exponent used in the calculation of vout voltage.

Referenced by IicPmbusPolledExample().

#define XIIC_BASEADDRESS   XPAR_XIIC_0_BASEADDR

Base address of the IIC device.

Referenced by IicPmbusPolledExample().

Function Documentation

int IicPmbusPolledExample ( void  )

Demonstrates PMBus access in polled mode.

It initializes IIC, selects the MUX (if enabled), reads VOUT and TEMP from the PMBus device, and prints the results.

Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE otherwise.

Initialize the IIC driver so that it is ready to use.

Start the IIC device.

Initialize the IIC MUX on boards where the PMBus devices are connected through the MUX.

Combine the two bytes into a 16-bit raw value, convert it to voltage using Linear16 format, scale it to centivolts, and print the result.

Convert raw PMBus temperature data (Linear11) to centi-degrees Celsius and print

References XIic_Config::BaseAddress, PMBUS_CMD_READ_TEMP, PMBUS_CMD_READ_VOUT, PMBUS_VOUT_EXPONENT, ReadBuffer, XIIC_BASEADDRESS, XIic_CfgInitialize(), XIic_LookupConfig(), and XIic_Start().

Referenced by main().

int main ( void  )

Runs the PMBus polled example.

Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE otherwise.

Run the PMBus example.

References IicPmbusPolledExample().

Variable Documentation

XIic IicInstance

The instance of the IIC device.

u8 ReadBuffer[2]

Buffer used to store data read from the PMBus device.