Data Acquisition with Zynq + FreeRTOS+TCP/IP Stack: Software

Post date: Oct 02, 2015 10:40:23 PM

Please see the last post on more information on what the project does, and a description on the programmable logic. In short, the project consists of sampling audio with the Avnet ZedBoard and several peripherals and then sending the audio data over Ethernet to another computer for playback. This post focuses on the software aspect of the project. All (embedded) software is written to run for only one of the two ARM CPUs.

(Embedded) Software Structure. As implied by the title of the project, the Zynq port of Real Time Engineers Ltd. FreeRTOS is the chosen operating system, but it’s important to note some of the operations from Xilinx Standalone are also called, specifically the drivers to configure interrupts and the AXI GPIO IP for driving the LEDs. Since FreeRTOS is running, it only made sense to try out the FreeRTOS+TCP/IP stack for communicating over the Giga Ethernet Port with another computer. After the configurations, such as creating tasks and starting drivers, the stack is used to create a TCP server on the CPU which initially sits and listens for a single client.

Servicing the Client. Below is a snippet of the task created once a client successfully connects to the server. The task first tells the CPU to start collecting samples in a buffer by enabling the corresponding interrupt, blocks on a notification (i.e. binary semaphore), disables interrupts when notified, sends the data to the client, and then finally releases the client and kills the task.

Code snippet of task that services the client. Note that the code that releases the socket and kills the task is omitted.

Collecting the Data. The snippet of the interrupt handler is presented below. The interrupt is configured to always trigger on the positive edge of the interrupt signal generated by the MBDataAcquisitionController implemented in programmable logic. Thus, whenever the interrupt is enabled, the handler only reads the audio samples when a new audio data sample is available. The sample is then stored in a buffer. When the buffer reaches its limit, the task that services the client is notified.

Interrupt handler for reading data from the MBDataAcquisitionController's AXI-Lite interface.

Client Software. The software running on the computer connected to the ZedBoard is a Python script that connects to the server, waits until the specified number of audio samples are collected, closes the client, and then plays the audio samples. In the future projects, there are plans to perform a more serious analysis of the data. But, for now, it is sufficient to simply let the captured data be heard.

Client code that runs on the connected computer.

Next Project. This was briefly mentioned in the last post, but the next project will consider PetaLinux.

Code. Only the "main.c" source file is really needed, since the FreeRTOS and the TCP/IP stack sources are all found on the FreeRTOS website. I simply included the source file with the other sources related to the project.