Você está na página 1de 2

ATMEGA8 PROCESSOR EXPERIMENTS

Experiment 1: In this experiment, the basic assembly level coding for ATMEGA8 processor will be
reviewed. The experiment is as follows:
a. Start the AVR studio 6 program.
b. Open a new project with name expt1_part1.
c. Add the sample assembly code given, build and run in the simulator.
d. In the AVR simulator, see the single stepping, observe the memory locations, registers etc.
Also learn how to set up breakpoints and stop at desired locations while running the code.
e. For programming the IC, use the Burn-o-mat program and the usbasp programmer, after the
AVR studio compiles and gives an hex file. This .hex file is produced in the Debug directory. Also
check the .lss list file for more details about included files.

Expt1: Part1:
As exercise, carry out the following experiments using the AVR simulator and show the results
to your TA:

1. Move two numbers A and B to two free registers. Add these two digital numbers A and B
and store the result to a specified memory location (0x0 060).
2. Subtract two numbers A and B (say, A > B) and store the result in a data memory location
(0x0062).
3. Produce a multiplication table of 5 x i ( I = 1 to 10) : store the results in RAM memory starting
from location 0x0060.
4. Write an assembly code for infinite loop operation. Also include an interrupt service routine
(ISR) program. Upon interrupt, the Program Counter PC and SP will move to the ISR location.
Write a code to check this. You can also simulate a HW interrupt in the simulator by setting
the interrupt bit to 1.

EXpt1: Part2:
In this second part, we program the IC using an USB programmer to blink an LED. Show the
results to your TA.

1. Create a new project and name it as expt1_part2. Write an assembly code for the following
LED blinking experiment.
2. Define Port D as output port and keep sending 0x00 and 0xFF to toggle an LED connected
to one of the D port lines. Connect the LED through a resistor, say about 1K. (See the
sample C code).
3. Rig up the programmer board to an ATMEGA8 IC on breadboard and test the code. See the
wiring diagrams in the moodle website. It is always a good idea to connect a 0.1uF
decoupling capacitor from Vcc to Gnd.
4. Write a delay subroutine to control the intensity of the LED. Check this assembly code in
the simulator first. Also change the delay subroutine to blink the LED slowly by having two
loops.
5. Do the same exercise in the C language using a built-in delay subroutine in the library. Also
single-step and check the C language code in the simulator. Find out from web how to
include an ISR routine in C code, if you want to use interrupts.

Você também pode gostar