You are on page 1of 2

Tutorial then June 27ᵗʰ

This tutorial content for Lab


covers 4+5

be done
Delay can 2 different
ways
:

1 . Times -
Also used for PWM I not covered in class
yet so we will use subroutine )
2 .
Subroutine

subroutine
-
We
normally run at -1MHz
,
% 1 machine
cycle
=
IcyI =
1µs

" "
IN
cycles

The instruction LDI RW ,
LW is one machine cycle .

Example delay :

Machine
cycles
delay : LDI RIG , OXFF
-

count 1 : LDI RIA ,


OXFF

} ]
count DEC Rlq 1 the (1+2)%56 Internal External
÷
:

BRINE count 2 z we ,
loop Loop
DEC 1218

BRNE count 1

0th) 42 Machine
=
,
% total cycles ≈ 2562

starting of that Basher

main : LDI Rl8 , LOWLRAMEND )


start init stack
out
SPL ,
RIG by
LDI RIG , HIGH ( RAMEND )

oat spine , no

RIG the 110


ports
CLR Next
setup
out DDRB ,
RIG

SER RIG

OUT DDRD ,
Rtb

*
Code continued next
page
on
?⃝
LED Blinking
-rLrw→
'

• EQU LED RIO →i t i. ←

LDI RIG ,
OXFF •

Delay of interval t .

6 aft
"

for
"
LDI RW , •
Use a counter n number intervals .

three blk SER 1221 After the


each
delay toggle output

_
: .

◦ utter : SER 1222

inner :
delay calculation (41-27256+(1+41)) -256
Eye
DEC 1222

=

BRNE inner

DEC RZI ≈ 0.23 see

BRNE outter

LDI RIG Oxff


,

EOR 1219
,
1218

Mov LED , Rl9


OUT PORTD , LED

DEC RW
BRINE three -
blk

the Rat
Generating
Bonus for randomly the rat
points displaying


Can also stare the rat location in the Roll and then that location to
pass
the Port .

Rats


DB

DB
OB
OB
oooo

oooo
0001

tooo
} ×
# of rats .

You might also like