user's manual

advertisement
User's Manual
Microcontroller ASIC Design (SD0923)
Adam Hoffert
Filipe Betzel
Tom Narvesen
Zachary Skalsky
Table of Contents
Introduction ............................................................................................................................................ 3
Components ........................................................................................................................................... 4
Getting Started ....................................................................................................................................... 5
Installing Software Tools ........................................................................................................................ 7
MSPGCC .............................................................................................................................................. 7
Windows installation ...................................................................................................................... 7
Linux Installation ............................................................................................................................ 7
Make ................................................................................................................................................... 9
Eclipse ................................................................................................................................................. 9
Octave............................................................................................................................................... 11
Configuring Project ............................................................................................................................... 13
Recompiling and loading code to the MSP430 ................................................................................ 13
Changing memory type .................................................................................................................... 13
Using the serial port for loading code .............................................................................................. 13
Changing the serial port number in the Windows application ........................................................ 14
Changing UART baud rate ................................................................................................................ 14
Quartus Settings ............................................................................................................................... 14
2
Introduction
This user manual describes the operation of the final product for the ASIC Microcontroller design
team (SD0923). The project was sponsored by Packet Digital (Fargo, ND), supervised by Brian Morlock
and Matthew Bitterman, and instructed by Dr. Mark Schroeder. The project was completed in May
2010.
The final project is comprised of three peripherals designed in Verilog: a UART (Universal
Asynchronous Receiver Transmitter), a SMBUS controller, and a 32 character LCD controller. These
peripherals were connected to the OpenMSPP430 (a 'soft' open source microcontroller). They were run
in an ALTERA DE2 FPGA development board. Additionally, a custom circuit board consisting of a
temperature sensor, an EEPROM, and a LED controller, all using the SMBUS protocol, was built, as well
as custom software to demonstrate the basic functionalities of our design.
The demonstration exemplified a possible application of our design as a temperature logging
station. It was able to store the temperature in a room over a long period of time, display it on the LCD
screen, set LEDs on and off based on the temperature, and transfer data to/from a PC using the serial
port.
This user manual is designed to provide a step by step procedure on how to properly setup and run
the final demonstration. It covers the required tools and software, as well as how to perform some of
the most basic configurations.
3
Components
Following is the list of necessary hardware, software and files to run the demo:

Altera DE2 development board

Custom made SMBUS circuit board

Serial cable

PC running Windows operating system

Quartus II

Octave*

main.sof

uart_interface.exe
Following is the list of necessary software for configuring the project:

Quartus II

MSPGCC*

Make*

Eclipse IDE (optional)*

openMSP430-loader (when using Serial Debug Interface)

Text editor

CodeBlocks (Windows C++ IDE)
*See installing software tools section on how to install
4
Getting Started
1. Connect the DE2 development board to power, the USB blaster to the computer, and the serial
cable to an available port in the computer
2. Connect the custom built board to the DE2. Check picture for proper pin location.
3. Run Quartus II
4. Go to Tools → programmer
5. Choose add file and browse to the location of the provided main.sof under FPGA → Altera DE2
board → synthesis
6. Load the configuration file unto the board
7. The program should start running automatically. If not, press KEY3 to reset.
8. Run uart_interface.exe on the host computer
5
9. Type one of the following commands
10. Type “exit” to quit
6
Installing Software Tools
MSPGCC
MSPGCC is an open source compiler designed for the MSP430 family of microcontrollers from Texas
Instruments. It supports most of the MSP430 models that TI manufactures. It supports the saame syntax
as used in the Texas Instruments' proprietary compilers. MSPGCC can be installed on both Windows and
Linux. The project website is http://mspgcc.sourceforge.net/
Windows installation
Installing MSPGCC in a PC running Windows is straight forward. Full installer packages are available
online at http://sourceforge.net/projects/mspgcc/
Linux Installation
Installing MSPGCC in Linux requires additional steps. Even though there are Linux installer packages
available, it is still advisable to recompile it from source. The following steps are taken from the MSPGCC
wiki page http://sourceforge.net/apps/mediawiki/mspgcc/index.php?title=Linux_installation
and have been successfully tested.
Fedora
Most of mspgcc is in the Fedora repositories now. Run the following:
su -c "yum install msp430-libc"
GDB isn't yet in the repositories, but you can get it here. You can install
it by running:
su -c "rpm -Uvh http://users.ecs.soton.ac.uk/rds/rpm/mspgcc/msp430-gdb-6.81.fc10.i386.rpm \
http://users.ecs.soton.ac.uk/rds/rpm/mspgcc/msp430-gdbproxy-0.7.11.fc10.i386.rpm"
7
That's all you'll need to do. The above commands will work for Fedora 11 as
well. The gdbproxy package includes the udev rules to initialise the TI
FET430 and EZ430 when they're plugged in.
cdk4msp also has the complete toolchain, but it's outdated.
Ubuntu
There are some packages for mspgcc in the Ubuntu repositories, but they don't
have all the recommended patches to support all targets. There is word that
some are on the way.
This How-To was tested on a clean kubuntu 8.10 set up.
Prearrangement
Install the necessary packages from the ubuntu-repository.
sudo apt-get install cvs gcc-3.4 patch ncurses-dev
Prepare the directory, where mspgcc will be installed, The idea of the
makefile is to install the tool chain to /opt/mspgcc. That way it is also
easy to remove the files later. Please replace $USER with your current
username
sudo mkdir -p /opt/mspgcc
sudo chown $USER.$USER /opt/mspgcc
mkdir -p /opt/mspgcc/sf
cd /opt/mspgcc/sf
Get the Sources and build the Package
We get the sources from sourceforge cvs. Building is easy, while we are using
the prepared buildscript from cvs. The requested passwort is empty <enter>.
cvs -d:pserver:anonymous@mspgcc.cvs.sourceforge.net:/cvsroot/mspgcc login
cvs -z3 -d:pserver:anonymous@mspgcc.cvs.sourceforge.net:/cvsroot/mspgcc co P .
cd packaging
make folders
CC=gcc-3.4 make build
This step needs some time. Please have a look at the log files in
/opt/mspgcc/sf/packaging/build and /opt/mspgcc/bin that the build process was
successfull.
Refinishing
Add path to mspgcc
Append line in ``/etc/environment``, so that the commands of the toolchain
are found:
kdesudo kate /etc/environment
Append the path to the line
PATH="...:/opt/mspgcc/bin"
8
You have to reboot to see the result of that change.
Get additional Components
Some parts of the mspgcc toolchain (gdbproxy, msp430 jtag driver) are not
available
in
cvs.
Get
the
binaries
from
http://www.softswitch.org/downloads/mspgcc/.
cd /opt/mspgcc/bin
wget http://www.soft-switch.org/downloads/mspgcc/msp430-gdbproxy
chmod 777 msp430-gdbproxy
cd /usr/lib
sudo wget http://www.soft-switch.org/downloads/mspgcc/libHIL.so
sudo wget http://www.soft-switch.org/downloads/mspgcc/libMSP430.so
Make
Make is a standard Linux tool that allows the organization of project file dependencies and custom
build steps for compiling the project. The project dependencies and function calls are defined in a
Makefile. This allows projects to be compiled from the command line without the need of Integrated
Development Environments (IDE). A Windows version of Make can be downloaded from
http://gnuwin32.sourceforge.net/packages/make.htm
The only required files in the Windows installations are the two dlls and the main application found
at (for default installation): C:\Program Files\GnuWin32\bin. These can copied straight into the project
working directory where the Makefile is located. Typing Make at the command line will initiate the build
sequence.
Eclipse
Eclipse is a general purpose IDE. It supports a number of plugin compilers. Eclipse was used in this
project to facilitate file management. It can be found at: http://www.eclipse.org/
To create a Make project:
1. Launch Eclipse
9
2. Go to File → New → C project
3. Enter a project name and select Makefile project
4. A new project folder will be created in your workspace directory
5. Copy the source code files to the new directory, along with the Makefile, linker file, and the
Make and dlls (in Windows)
6. Right click your project in Project Explorer → Make targets → Create. Target name: all . Make
target: all
10
Eclipse can also be used to compile and debug code for the MSP430 directly (without makefile). In
order to do so, it needs to be configured to use the MSPGCC compiler, and additional debugging tools
must be added to Eclipse, such as the Zylin Embedded CDT. The following webpage provides good stepby-step
instructions
on
how
to
configure
Eclipse
for
the
MSP430:
http://matthias-
hartmann.blogspot.com/2009/02/use-eclipse-and-mspgcc-easy-way.html
The OpenMSP430 manual provides list of MSP430 devices to aid on the selection of the right MCU
model. It also explains how to use the openms430-gdbproxy tool for debugging the MSP430 using the
serial port.
Octave
Octave is another free software that performs numerical computations, and that has a syntax similar
to MATLAB. It is found at http://www.gnu.org/software/octave/
In order to get the “plottemp” function in the uart_interface.exe to automatically display of
temperature plot, the following procedures must be followed after Octave has been installed on the
system (assuming Windows):
1. Browse to the installation folder. Default C:\Program Files\Octave\bin
2. Make a copy of octave-3.0.1.exe and name it octave2.exe
11
3. Go to Start → Right-click Computer → Properties → Advanced → Environment Variables →
Under user variables select PATH (or create it) → Edit → Add the installation folder path
like in (1) → OK.
4. Octave should automatically run when the “plottemp” function is called.
12
Configuring Project
Recompiling and loading code to the MSP430
In order to modify the functionality of the MSP430 one should edit primarily the main.c file. Defined
functions and variables declarations can be found in the uart_defines.h, smbus_defines.h, and
lcd_defines.h. To recompile the code:
1. Make sure MSPGCC is installed in the system
For Windows:
2. Have all the source code, make, the required dlls (see Make install section), the link file (link.ld),
mifwrite.exe (if loading code through Quartus), openMSP430-loader.exe (if loading code
through serial port), and the Makefile
3. Open a command line window. Browse to the folder and type 'Make'. This should recompile.
Quartus can also be used to load a .mif file using Memory Content Editor.
Note: in order to load code throguh the serial port the openMSP430 must be using an Altera RAM
for program memory. On the other hand, for loading using Quartus it must be using ROM.
Changing memory type
The type of program and data memory that the microcontroller will use can be changed by
configuring the OpenMSP430_fpga.v file. Data memory can be chosen to use Altera RAM or the SRAM
chip available in the DE2 (both set to 2K). The program memory can be chosen between a 4K RAM or
ROM, depending on how the software will be loaded.
Using the serial port for loading code
Besides loading the C code using the Quartus memory content editor, the openMSP430 allows an elf
file to be loaded using the serial port. It uses a tool called the openMSP430-loader, which can be
13
included in the Makefile for a one click compile/load. Check the following before attempting to use this
tool:
1. Program memory type is set to RAM in the opwnMSP430_fpga.v file
2. Serial debug is enabled in openMSP430_defines.v
3. Switch 0 in the development board is set to high
Changing the serial port number in the Windows application
The uart_interface.exe is set to utilize serial port COM5. This can be easily echanged by modifying
the respective parameter in the main.cpp file and recompiling it. CodeBlocks has been used to compile
this program, and issues have been found when trying to compile it using Visual Studio.
Changing UART baud rate
The baud rate for the UART can be changed in the baud_generator.v file. It should also be updated
in the main.cpp for the Windows application for proper operation.
Quartus Settings
These were the applied settings in Quartus:
Assignments → settings
“compilation process settings”
turn off “smart compilation”
“incremental compilation”
full incremental compilation
“analysis and synthesis”
auto open drain technique
Under advanced:
14
-extract verilog state machines = off
-extract VHDL state machines = off
-NOT gate pushback = on
-safe state machine = on
“Fitter Settings”
optimize hod timing = all paths
“design assistant”
hard copy rules = unchecked
finite state machine = checked
15
Download