Harvest 1: Zynqberry UART Command IO

With the bare bones project or “template” established, it was time to really start exploring the Zynqberry. Since it has quite a bit of functionality combined into the micro-USB port, I wanted to keep down that path. The idea of having a set up that could get away with one sole cable is quite appealing to me and seemed like a great thing to have in my back pocket in case the event arose in the future that I might need such a setup.

Since the micro-USB on the Zynqberry already takes care of supplying power and the JTAG, the only thing it was really lacking was being able to accept command inputs from a host PC. Just for the fun of it, I opted to create a bare metal application to do this (Why? Because I wanted to, that’s why. PetaLinux is coming up in later blogs anyways so don’t worry).

To kick off as a proof of concept, I started with a character echo application. Super bare bones as it can get, where I’m literally just reading & writing to the UART registers by stepping through a simple state machine using a switch-case statement.

Single character echo.

Single character echo.

This state machine simply monitors the receiver status register of the UART device in the Zynq. There is a canned function in the SDK library for the UART interface that returns true or false in relation to the presence of data in the receiver FIFO. Once this function returns true, the state machine steps through to read in each character out of the receiver FIFO, then write it to the transmit FIFO for the UART to write out to the console. Even though the state machine is reading and writing one character at a time, it will do so until the status register of the receiver reads back false that any data is left in the FIFO. This means a full string of characters can be sent and echoed back at once.

Full string echo.

Full string echo.

At this point, one can simply add more cases to the switch-case statement for actions based upon the characters/values read in from the receiver. I’ve uploaded my main file for this application to a repo I’ve created for this blog so you can copy it over and add to it for your own custom application.

https://github.com/wknitter/zynqberry/tree/master/uart_io

I know this is on the shorter side for a proper blog entry, but bare with me as I figure out how to overcome my procrastination and get on a regular posting schedule!