Beruflich Dokumente
Kultur Dokumente
called
tv
Cl
Bl
-
-
i
i
have PORTB PORTC Po RTD
.
at
we
PORTA on
-
-
, .
, ,
-
Do
BG B 4
PORT B : B7 BS BS BL BI Bo
other ports
some
for the
, every port is 8 biforate )
To write to the
pins we use Porta ( .bg
? )
§
F.
To read
from 11 it
'
I 4 PINK
To define o -
pin as I or O we use DD Rsc
In DDR x
to
-
bit bribe
I
:
,Yp
con ending
Yin
÷ input
output
: ,
E L DI RIG ,
ox e3
OUT DD RC ,
R " Outputs
76 s 4 32 to
DDRC XC 3 I I 00 00 I I
⇒ = o =
CG and Ct
⇒ Fo ,
c
, ,
are
and L2 ,C3 ,
CG and CS are
inputs
ee : Define Port D as output then toggle ②
it
forever .
-
1111 1111
ly ⇒ old
pins of
OUT DDRD RIG
,
port bone outputs
loop RIG
}
0
i
LDI ,
PORT D= oooo oooo
OUT Po RTD ,
Rig
)
L DI RIG ,
OXFF
port D= 1111 1111
out PORT D ,
Rtb
amp loop
E Define Bo
, Bg ,
Be , and Bt as
input
and the other pins of PORTB as outputs
3 2 I
7 6 S 4 o
Sold L d d L d L d L
DDRB :
o I I O 0 I I °
=
OX 66
⇒ The Solution is :
L DI RIG ,
O X 66
OUT DDRB ,
R 16
I/o Bit Manipulation ③
SBI K
iorey ,
C BI :
Cleon Bit in I/o Register
C BI io
Reg ,
K
the
ED Trace
following assembly program
AT
LD I R 16 ,
OX FF Solt ① RIG -
- OXFF
DUT DDRC ,
RIG ② DDRC -
- OXFF ⇒ all
pins of core output
LD I RIG OX At
, ③ Rib = ox
Po R 16 Porte XA 't
RTC ④
o
OUT
-
,
1010 0 111
Po
=
S BI RTC 4
,
Porte
⑤
=
C B I Porte ,
7
I O I I O I I I
C BE Po RTC ,
5 ⑥ o o I I 0111
RTC
S BE Po , 3
⑦ ooo I 0 111
⑧ 00 O I I I I I
⇒ Po RTC = ox IF
Crete
ED o -
square
wove on CL .
Suppose ④
we
have a subroutine called oblong
-
.
all it
between
every toggle
soy
in bit 2=1
C 2 : output ⇒
DDRC
wave ⇒ Cz 51-17-17 - . .
square
: ,
S B I DD Re ,
2 ← cos : output
B I Po RTC 2 L2 o
again : C , ←
=
CALL
delay
S BI Po RTC 2 cod = I
, ←
CALL delay
ymp again
checking on
input pin ( Rooting ) ⑤
S BI S .
.
SB IS
Ioneg ,
hi
mb.hr in Io is I
neg
=
S BIC :
Skip meet instructor if
B it in I/o is Clear
SB Ic Io h
-
neg ,
⇒
skip
nut instruction if the
E CBI DDR B ,
3 → B. 3 is
input
LD I Rib O R 16=0
, →
LD I RIG , I -
Mov RIO ,
Rib
RIO
if
o
⇒ B 3=1 ⇒ =
RIO =L
if B3=o ⇒
until
Ee keep monitoring B2 it bacon
42 in
ox
PORT C
bit
Soy BE input ⇒ 2 in DPRB o
-
1111 = OX FF
DDR c =
1111
CBI DDRB ,
2 → B2 input
,ox42jII
OXFF
}
LDI R 16 ,
Porte output
OUT DDRC ,
rig
again : SB IS PEN B
,
2
executed if B2=o
Jmp again →
if switch
'
send to Po
'
o ⇒ N RTD
(
=
switch I
'
to Po
'
it
y RTD
-
-
⇒
⇒ -
'
we need Ee write '
N
'
or
'
y to Po RTD
go
Sdsu
④ CBI DDRB
,
5 CBI DDRB
RIB
,
OXFF
5
LDI
< DI Rib ,
OXFF ,
No
grip yes
jmp I
'
I
' LDI RIG ,
W
LDI Rib , y
OUT PORTD , Rif
OUT PORTD Rtb
,