Please enable JavaScript to view this site.

Waijung 2 User Guide

Design overview

I2C block appearance in a Simulink model,

zynq_7000_i2c_master_block_1

I2C block mask overview,

Block Name

Mask

I2C Master Setup

zynq_7000_i2c_master_block_2

I2C Master Transaction

zynq_7000_i2c_master_block_3

I2C Block input interfaces

I2C Master Setup

Name

Type

Range

Description

N/A

 

 

 

I2C Master Transactions

Name

Type

Range

Description

Slave Address

uint8 | Scalar

0 - 255

If Input port option is selected as the Slave address source in the block mask this input port will appear. The user can use this port to specify the slave address of the I2C device.

Wr{n} (uint8)

uint8 | Scalar

0 - 255

Depending on the number specified for the Bytes write count parameter, these input ports will appear. This port should be used to specify the n th write byte value.

I2C Block output interfaces

I2C Master Setup

Name

Type

Range

Description

IRQ

Function-call

 

This will appear when the Interrupt mode is enabled. Multiple interrupts are represented with a single Function-call output port. To split it to separate ports, use

Demux Block in Simulink.

I2C Master Transaction

Name

Type

Range

Description

Status

uint16 | Scalar

0

If it is,

0: Success

1: Failure

1089:  Arbitration lost for master

1

1089

Rd{n} (uint8)

uint8 | Scalar

0 - 255

Depending on the number specified for the Bytes write count parameter, these input ports will appear. This port should be used to get the n th read byte value.

I2C Block behavior

This is an implementation of I2C driver in the PS block. This implementation supports both interrupt mode transfer and polled mode transfer. The I2C Master Setup block is used to configure the I2C driver in polled or interrupt mode. There are two I2C devices in Zynq 7000. Therefore, up to 2 setup blocks can exist in the same Simulink model file.

The I2C Master Transaction block is used to execute I2C write/read transactions. There can be any number of transaction blocks in the same Simulink model file.

I2C Block configuration

The following parameters can be configured through block mask of I2C Master Setup.

Configuration Parameter

Selectable Option/Value        

Default Value

Description

DEVICE ID

XPAR_PS7_I2C_0_DEVICE_ID

XPAR_PS7_I2C_0_DEVICE_ID

Depending on the peripheral availability in your hardware design created using the Vivado Design Suite, available device-ids will be shown.

XPAR_PS7_I2C_1_DEVICE_ID

Transfer mode

Polled

Interrupt-driven

Polled

Select the transfer mode

Transfer timed out

on

off

off

Enable/disable transfer timed out interrupt. This will only appear when Interrupt-driven is selected as the Transfer mode.

Receive error

on

off

off

Enable/disable receive error interrupt. This will only appear when Interrupt-driven is selected as the Transfer mode.

Arbitration lost

on

off

off

Enable/disable arbitration lost interrupt. This will only appear when Interrupt-driven is selected as the Transfer mode.

NACK received

on

off

off

Enable/disable NACK received interrupt. This will only appear when Interrupt-driven is selected as the Transfer mode.

RX overflow

on

off

off

Enable/disable RX overflow interrupt. This will only appear when Interrupt-driven is selected as the Transfer mode.

TX overflow

on

off

off

Enable/disable TX overflow interrupt. This will only appear when Interrupt-driven is selected as the Transfer mode.

RX underflow

on

off

off

Enable/disable RX underflow interrupt. This will only appear when Interrupt-driven is selected as the Transfer mode.

Clock speed (kHz)

100

400

100

Select the clock speed for communication

The following parameters can be configured through block mask of I2C Master Transaction.

Configuration Parameter

Selectable Option/Value

Default Value

Description

DEVICE ID

XPAR_PS7_I2C_0_DEVICE_ID

XPAR_PS7_I2C_0_DEVICE_ID

Depending on device-ids specified in the I2C Master Setup blocks, available devices will be shown in the drop down.

XPAR_PS7_I2C_1_DEVICE_ID

Slave address source

Input port

Specify via dialog

Input port

If the Input port option is selected, the Slave address input port appears. If the Specify via dialog option is selected, a text box will appear on the mask to specify the slave address.

Bytes write count

 

1

Number of bytes to write

Bytes read count

 

1

Number of bytes to read

Sample time (sec)

-1 (inherited) or specify

-1

Specify the sample time for the block in seconds.

I2C Block limitations

N/A

Troubleshooting

N/A

Typical application

Several demo files are provided at:

[<waijung2 installation directory>\waijung2\targets\zynq7000\demo\i2c_demo]

To load the model file run the following commands in the Matlab Command Window:

Demo 1: waijung2.openDemoInCurrentFolder('zynq7000', 'i2c_demo1')

Demo 2: waijung2.openDemoInCurrentFolder('zynq7000', 'i2c_demo2')

 

Copyright 2023 Aimagin Co.,Ltd. Rev.779