The AVR card contains a Mega88PB with eighteen user accessible IO pins. Programming and host communication is through the SPI port. This page tells how to compile, download, and test AVR programs using the AVR card.
This page is organized as follows:
Most Linux installations use gcc-avr for compiling applications for the AVR. Install avr-gcc with the following:
apt-get install avr-gcc avr-libc binutils-avr
Source code for the blinking LED application that ships with the AVR card is part of the dpserver source code. Download dpserver, change to the AVR sample application directory, and build the application with the following:
cd /tmp git clone --depth=1 https://www.demandperipherals.com:3000/Demand_Peripherals/dpserver.git cd dpserver/drivers/avr/Code/samples/led make
Be sure that led.hex was created from the make command.
The AVR SPI port is used for both code download and for host communication. A jumper on the board distinguishes between the two. Install the jumper to flash a program or to set values in the EEPROM. Install the jumper on the card. Be sure your FPGA image includes the avr peripheral and that the card is connected to the correct peripheral cable. Status messages from the AVR programmer are sent to stdout. To see these messages you should start dpserver as:
/usr/local/dpserver -ef /dev/ttyUSB0
Verify that the server is running and that the avr peripheral is included with:
The server is usually started as a daemon and switches to the root directory ('/') before starting execution. When you specify a hex file to program the path is relative to the server's working directory. This means you need to give the full path name to the hex file when downloading to the AVR card. Flash your demo LED application with the following command:
/usr/local/dpset avr program /tmp/dpserver/drivers/avr/Code/samples/led/led.hex
The led program uses the first virtual address (address zero) as the delay constant. Test your installed led application by removing the jumper and trying different values for the delay constant.
/usr/local/dpset avr vram 00 44 /usr/local/dpset avr vram 00 11 /usr/local/dpset avr vram 00 ee
The led sample application maps virtual address zero to the first byte in the hostRegs array. The hostRegs array is defined in dpavr.h and you can rename as you see fit. Be sure to change the corresponding entries in the SPI interrupt code as well.
You can set the power up default value of the LED delay by setting the first value in the EEPROM. Install the programming jumper and issue the following command to set the default:
/usr/local/dpset avr eeprom 00 11