You are on page 1of 4

ECE4330 – Embedded System Design Lab 1 – Introduction to Embedded Systems

1-1
Introduction to Embedded Systems
In this lab you will perform tasks designed to acquaint you with the ATMEL AVR Starter
Kit 500 (STK500), a prototyping/development board. Also, you will become familiar
with the C-compiler from CodeVision.
The board is programmed and controlled by CodeVision’s C-Compiler software that is
installed on the lab’s PCs. This software package along with the STK 500 starter kit
makes it possible to quickly develop and verify the design of micro-controller
applications.
Figure 1-1 – Typical Hardware Inter-connections

PC
STK500
COM1
COM2
RS-232 Cable
RS-232 Cable
ISP6PIN
SPROG3

CAUTION! Even this seemingly simple, introductory lab is time-consuming if working
with the STK500 (hardware board) and the CodeVision C-compiler for the first time.
Pre-lab Assignments
1. Read Chapter 1 of the textbook: Embedded C Programming and the Atmel AVR
by Barnett, Cox, & O’Cull (BCO).
2. Complete the Pre-lab Questions on page 1-4.
In-Lab Tasks
In-Lab Tasks are a suggestion for the minimum amount of work to complete in the lab.
You must maintain lab safety, such as unplugging the STK500 when appropriate.
However, feel free to do more and varied tasks than what are detailed. Document and
report in your lab write-up all of your lab efforts. For each of the following subprograms,
create a new project.
1. Print out and follow all the steps necessary to complete the tutorial “Getting
Started with the CodeVision AVR C Compiler.”
2. Repeat these steps on your own to make a different pattern on the LED’s
using the same interrupt scheme as used in the tutorial. Call this program
led2.c.
3. At this point you have used timer1 to generate an interrupt so that the
frequency of the blinking lights has been half of a second. Now, instead of
using a timer/interrupt to control the frequency of the lights, use a delay
function to control the frequency. Write code that generates a different
ECE4330 – Embedded System Design Lab 1 – Introduction to Embedded Systems

1-2
pattern and use a value of ¼ of a second as your frequency. Call this program
led3.c
4. Write a program that generates a “Hello World” message to the screen.
a) Turn OFF the STK 500.
b) Use a second serial RS-232 cable to connect the port labeled “RS232
SPARE” on the STK500 to COM2 port on the PC.
c) Remove the 10-wire cable linking PORTD to SWITCHES. Add a new
two-wire cable between RS232/SPARE to PD0/PD1. This connects I/O
from PortD bits 0 and 1 to the RS232 cable.
d) Turn ON the STK500.
e) When using the code generating function in the CodeVision software you
now must select the UART tab and select the Receiver and Transmitter
options that appear there. This will automatically include the stdio.h
library for you to use.
f) Before running the C-program on the STK-500, you will need to start a
routine on the PC that uses COM2 on the PC for serial communications.
To do this you need to open the terminal window in the CodeVision AVR
C-Compiler.
g) For this utility the connection should be at 9600 baud, 8-data bits, 1 stop-
bit, no parity. Check the appropriate menu option to make sure the
settings are correct.
h) Write code that generates a “hello world” message to the screen every half
second using either a delay function or an interrupt. Call this program
HelloWorld.c.
Parts List
The items on this list will not be repeated in each lab write-up, but they are necessary for
all labs.
1. PC
2. STK500
3. 6 wire cable
4. RS-232 cable
Parts for Lab 1:
1. A second RS-232 cable
2. 10-wire cable (2)
3. 2-wire cable
Deliverables
1. Lab Write-up. This is a technical document. Use complete sentences and logical
paragraphs. Document any changes you made to the programs in both the report
and on the program listings. Feel free to make changes and “do your own thing”,
ECE4330 – Embedded System Design Lab 1 – Introduction to Embedded Systems

1-3
just so long as your efforts are greater than what is requested by the assigned
tasks. For this first lab a one or two page write-up is sufficient. Later labs will
require more effort.
2. Program listings. Print a hardcopy of the c code you wrote and was generated by
the CodeVision software. Include listings for all four programs:
a. led.c
b. led2.c
c. led3.c
d. HelloWorld.c
3. Demonstrate to the lab instructor your three led programs and the Hello World
program.
ECE4330 – Embedded System Design Lab 1 – Introduction to Embedded Systems

1-4
Pre-Lab Questions for Lab 1
Name: ______________________________
2 points each, 10 points total. Be sure to include units, as appropriate, with your answers.
1. When setting up a timer to generate an interrupt every half second, what value
must the timer be initialized to (if counting down)?

2. What is the clock frequency of the AVR mcu on the STK500 when shipped?

3. On the average, how many clock cycles are required per instruction?

4. Using your answers from questions 2) and 3) above, how long does a typical
instruction take to run on the AVR mcu?

5. Write pseudo c-code to toggle every other light to blink every ¼ of a second.
Example: 01010101 -> 10101010 -> 01010101 ->…