FPGA design from scratch. Part 91
Writing software to control the accelerometer
We will use Xilinx Software Development Kit (SDK) for the software development. To start a software project in SDK, the hardware design information needs to be exported from XPS to SDK. In XPS go to Project->Export Hardware Design to SDK and click Export Only.For more information about software development see part 66.
--> xsdk &
Start SDK and select a new workspace for our software project.
Starting a new project
Select New C Project from the File menu.
The first thing we have to do when starting a new project in SDK is to setup the hardware platform. We will do that by finding the XML file: LX9_AXI_ACL_system.xml and select it as the target hardware specification file.
Creating a new C-project
We call our new C project adxl345_control and start with an empty application.
We create a new board support package called adxl345_bsp_0
Adding c-program files
Because we are not the best c programmers and a bit lazy we will copy the c-files from the Avnet installation we have already downloaded. After copying the files to the src directory we have to do a refresh to see the files in SDK.
Here is the final result ready to be compiled and built.
Before we can compile our application there are a few things we have to fix.
- Generate a linker script
- Edit the cf_adxl345_sw.c file
Generate a linker script
We will setup the linker to put all the code in the MicroBlaze BRAM.
Edit the c-program
There are two small changes to be made.
Building the project
Here is the print out from the build process. Everything looks OK.
Configure the Spartan-6 FPGA
In SDK select Xilinx Tools->Program FPGA. Select the program ELF file to be loaded to the BRAM.
Start the console
Start gtkterm or an other console program you prefer.
--> gtkterm &
Start program execution
From the SDK menu select Run As->Run Configuration. Select the USB port to connect to the terminal and set the baud rate to 9600. Click RUN to start the program.
After a few seconds this print out appears on the console screen.
When twisting and moving the board the values change. A great example of what we can achieve with this simple setup.
Top Previous Next