top of page

MicroZed Chronicles: ZU1CG Board and Click Interface

One of the great features about the new Avnet ZU1CG board is the interfacing it provides. It gives us three SYZYGY interfaces along with support for click board via a mikroBUS interface. If you are not familiar with the mikroBUS interface, it was developed by MIKROE to interface with a range of different click boards which provide functionality from LCD and displays to sensors, actuators, and communication. There are currently over 1200 different types of click boards.


The devices used on click boards use a range of common interfaces such as RS232, SPI, I2C, pulse width modulation and analogue interfaces. As such, the mikroBUS is designed to provide all those interfaces in a compact footprint.

I have a few click boards from the work we have done with the Ultra96-V2 and its click mezzanine so I thought it would be good to work with them on the ZU1CG board.

The click board I selected was the air quality sensor. This click board reports the estimated air quality by reporting the CO2 content over an I2C interface. It’s a simple interface. No addressing or configuration is required and you only have to read nine bytes over I2C.


To get started using the board, I created a new project in Vivado targeting the ZU1CG board.

With the project opened, the next step is to create a block diagram and add in the Zynq MPSoC processing system and configure it for the ZU1CG board.

With a block diagram created, we are also able to work with the board tab in Vivado. One of the nice things about the board definitions for the ZU1CG board is that the various click options are integrated under the board tab making easy connection to the appropriate mikroBUS signals. This saves us having to write constraints for the pins as they are already known by Vivado.


We can add the PL Click I2C interface to the block design by dragging it on to the canvas.

Once the PL I2C interface is on the block diagram, run the connection automation and the final design should look like the image below.

We can now build the design in Vivado and export the hardware XSA to Vitis so that we can create the software application.


In Vitis, create a new project targeting the XSA just exported.

Select PSU_CORTEXT53_0 as the target processor and select the hello world template for the application.

Once the application is created, we can enter the software code below which uses the low-level Xilinx IIC drivers to read nine bytes from the sensor. The sensor has an address of x5A. The first and second bytes are the predicted CO2 level by the sensor and byte 3 indicates if when the data is OK. When byte 3 is 0x00, the data presented in bytes 1 and 2 is seen as valid. In this case, we output the prediction over the USB UART.

#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "xiic_l.h"

#define IIC_BASE_ADDRESS        XPAR_IIC_0_BASEADDR
#define IIC_SENSOR_ADDR          0x5A

int main()
{
   init_platform();

                int ByteCount;
                u8 rxBuff[9];
                u16 co2;
                while(1){
                ByteCount = XIic_Recv(IIC_BASE_ADDRESS, IIC_SENSOR_ADDR,
                                     &rxBuff, 9, XIIC_STOP);
                                co2 = rxBuff[0]<<8 | rxBuff[1];
                                if (rxBuff[2] == 0x00){
                                printf("CO2 PPM = %d\n\r",co2);
                                }
                                usleep(5000000);
                }
   cleanup_platform();
   return 0;
}

The results can be seen below of the software running on the board.

Getting this design up and running was as simple as expected and the inclusion of mikroBUS connections in the board definition makes the integration even easier.


The SYZYGY interfaces are also defined in the board tab. We will take a look at working with these interfaces in an upcoming blog because they provide higher speed interfacing capabilities.


Upcoming Webinars

Perfecting Petalinux - Hands on Workshop for creating Petalinux Solutions on Xilinx SoC and FPGA. Registration


Embedded System Book

Do you want to know more about designing embedded systems from scratch? Check out our book on creating embedded systems. This book will walk you through all the stages of requirements, architecture, component selection, schematics, layout, and FPGA / software design.


We designed and manufactured the board at the heart of the book! The schematics and layout are available in Altium here


Learn more about the board (see previous blogs on Bring up, DDR validation, USB, Sensors) and view the schematics here.



Sponsored by AMD Xilinx





0 comments

Comments


bottom of page