I recently came across the problem that I needed a PWM (i.e. pulse-width modulated rectangular signal) generator block in Simulink with variable frequency and duty cycle inputs. I couldn’t find one in the library, so I wrote one.
The rather simple implementation basically consists of three parts: An integrator block with an external reset input is used to create a sawtooth signal. The sawtooth is then compared to a threshold value given by means of the duty cycle to create a rectangular signal. Lastly that signal is scaled to a standard output range of 0..1.
Just a quick and dirty non-tutorial solution on how to use the multiplexed I/Os (MIO/GPIO) to wire the BTN4 button on the ZYBO board (MIO50, the right one) to the LD4 LED (MIO7). Both are connected directly to the processing system and cannot be controlled from the fabric.
#include "platform.h"
#include "xparameters.h"
#include "xgpiops.h"
#include "xstatus.h"
#define GPIO_DEVICE_ID XPAR_XGPIOPS_0_DEVICE_ID
#define OUTPUT_PIN 7 /* MIO7, pin connected to LED */
#define INPUT_PIN 50 /* MIO50, pin connected to button */
int main()
{
int Status;
XGpioPs Gpio;
XGpioPs_Config *ConfigPtr;
// Initialize the system
init_platform();
// initialize the GPIO driver.
ConfigPtr = XGpioPs_LookupConfig(GPIO_DEVICE_ID);
Status = XGpioPs_CfgInitialize(&Gpio, ConfigPtr, ConfigPtr->BaseAddr);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
// configure the LED pin as output
// status checks skipped for readability
XGpioPs_SetDirectionPin(&Gpio, OUTPUT_PIN, 1);
XGpioPs_SetOutputEnablePin(&Gpio, OUTPUT_PIN, 1);
// configure the button pin as input
XGpioPs_SetDirectionPin(&Gpio, INPUT_PIN, 0);
// wire the button to the LED (inverted)
while(1)
{
u32 data = XGpioPs_ReadPin(&Gpio, INPUT_PIN);
XGpioPs_WritePin(&Gpio, OUTPUT_PIN, !data);
}
return 0;
}
Note that when you open the system.mss file in SDK, you’ll find the ps7_gpio_0 entry under the Peripheral Drivers section. Click “Example” there to find more information.
März 6th, 2014 GMT +2 von
Markus
2014-03-6T08:23:11+02:002014-03-6T16:28:25+02:00
· 0 Kommentare
Because I desperately searched for something like that and found nothing, I just wrote a tutorial myself on how to start with the Xilinx PlanAhead workflow in ISE 14.7 when using the Digilent ZYBO board. Though I made this with the ZYBO in mind, the general workflow also applies to ZedBoard users and probably general Zynq boards as well.
After exporting the implemented and generated project from PlanAhead to Xilinx SDK and having generated a Board Support Package, the build stops with an error due to make crashing with a rather dubious message along the lines of
It turned out that this is due to an existing installation of Git, when the Git directory is added to the path. Specifically, sh.exe is the problem here and simply removing that from (or renaming it in) the Git installation directory solves the problem.
März 4th, 2014 GMT +2 von
Markus
2014-03-4T00:01:57+02:002014-03-5T05:45:44+02:00
· 1 Kommentar
The ZYBO is an evaluation board for the Xilinx Zynq-7010 All-Programmable SoC made by Digilent. I got mine from Trenz Electronic at a reduced price for academic use.
I chose it over the ZedBoard (which I already have some experience with) because of the reduced size and since I don’t need the high-density I/O jack. It turns out though that the board is very small, yet quite heavy.
One thing to keep in mind though is that despite the rather large number of PMOD connectors, not all of them might be actually useful for a given task. The one on the left is connected to the Cortex processor, the right one is mixed analog/digital, and the three lower right ones are differential, leaving exactly the one on the lower left as a logic-dedicated PMOD for the FPGA (i.e. a single ended one that is connected directly to the FPGA, apart from the XADC one, of course).
I originally intended the board to be used to experiment with the OV7670 camera, but that might turn out to be a problem because of the PMODs. So: Caveat emptor.
I had some trouble getting Digilent Adept and/or iMPACT to recognize my board (despite having installed the necessary plugins), because I had downloaded the wrong version of Digilent Adept — sadly the search box on the Digilent website yielded Adept 2.3 as the best hit, which is outdated. After downloading the recent version from here, everything worked as expected and the device was correctly identified by iMPACT.
Unfortunately, while Digilent’s own software, Adept, was now able to talk to the board too, it was still unable to recognize the chip.
Edit: After asking Digilent support I received a mail saying that the Zybo can’t be programmed with Adept, so that’s expected behavior.
Edit: I wrote up a quick-start tutorial for the ZYBO. You can read more about it here.
März 3rd, 2014 GMT +2 von
Markus
2014-03-3T18:13:12+02:002014-03-16T17:03:26+02:00
· 2 Kommentare