Вы находитесь на странице: 1из 135

..

..


-
( AM)
,

- " "
( 210200 - "
( )

2005

681.325.5-181.48:681.51 (075.8)+681.51:681.325.5-181.48(075.8)
.., ..
: . - : - , 2005. - 133 .
,
657900 ,

,
, ,
.
,

, ,
,
.
.12.

-
.

:
.. - - . , ,
() ,
;
.. - - . , , . .

ISBN 5-8327-0206-9


, 2005
..,.., 2005

1.

1.1.
1.2. . . . .
1.3.
1.4.
1.5. -
2. AVR
2.1. AVR
2.2. AT90S8535
2.3 AT90S8535 .
3.
AT90S8535
3.1. -
3.2. SPI
3.3. UART
3.4.
3.4.1. 0
3.4.2. 1
3.4.3. 2
3.5.
3.6. - ()
3.7. EEPROM
3.8. . . .
4.
AVR
4.1. AVR
4.1.1.
4.1.2.
4.1.3.
4.1.4. . . . .
4.1.5.
4.2. AVR . . .
5.
5.1. AVR . . .
5.2. .
5.3.
5.4. AVR
. .

4
9
9
19
23
28
32
37
38
39
43
46
46
48
52
54
55
57
61
63
64
66
66
74
75
76
79
84
87
89
90
95
96
104
123
127
130
130
131


,
XX ,
.
,
, ..
,
.


.

,

.
. ,
,
.


, .

, , .
-
.

"" , ,
: ,
, ..
, ""
,

.

,
, .
,
, .. .

,
, .
4

. 1.

.
:

1 "3
1

\*\

so

1 X .
>*

3"

1 Su
1

'


<->

>s
0 >s

> >S

t
1
1
1

. 1.
-
, ;
-
;
- ,

, ,

;
-

;
5

-

, , ,
,
.
- ,
X
:

Y = !F(X) .
0
. .
:


.
,
.
. ,

.
.
- .
0

(). -
, -
.
,
,
.

:

.
, ,
.
: , , ,

, .
,
.
() 6

- . ,


,
.
,
.
.
(
, , , ..).

,
,
(PROM).

.

,
. ,
, ..
,
. ,
.

,
.

. ,

,
. - ,
,
,
.

, .

,
,
,
. ,
. , 7

4*sw - () ,
;
4*HW - ()
.

, ,
()- (4*Sw)
, , ,

.
,
,
. ,
.
,
,

.

.


.
.
Intel
8080. ,
30 , Intel 8080

.

1.0
70- XX

. ,

- - .


,
. ,
, -
,
.
1.1.
, ,

.
~
. - ,
,
, ,
.
( )
, ..
, ,
.
, ,
.
:
,
.

.

.
,
.
(, ) ,
. ,

, 9


.
-
. ,
,
.
-,
.
-

. ,

.
- ()
.
.
- . ()
, () ,
, ()
.
:

. ,
. -,
,
,
. -,
,
.
-,
, ,
- .
.
, , ,

, ,
.
,
, . 2. ,
-

10

>
S>
:>

<>

. 2.

V V V

, Intel 8080 (
- 58080).
, (,
[1]),
( ),
Intel 8080.
(. 2) (
) - ( )
,
.
(8 )
.

(16 ) ,
.
,
, , ,
.
(. 2) ,
, ,
,
. ,
(),
, - ,
,
.
()
.
- .
(hardware) (software)
.
, ,
,
,
.
- - (. 2).
, ,
( ), (
), , , ,
.. - (8
),
.
12


, - . ,
2
, - - ,
.
,
: - 6
(). ()
,
.
.
, ,
(. 2), .
,
- 7 ( 6 ),
, .
,

,
.
- . 6 ( , ,
D, E, H, L, . 2)
, DE, HL
.
,
.

2 16 = 64 .
,
, ,
.

,
-. , ,

.

64 ,
. ,
-
.
(2 ), ,
. 13



.

:
1.

, .
2. ( )
.
3. ,
; ,

( .. 1 2 ) .
4.
,
(. . 1).

. , D1
D2 1 2,
A3,

4.

,

.

Intel 8080 :
ml: Ida Al

; D1 1
;
2: mov , ;
13 Ida 2
; D2 2
; .
4: add
;
; (D1+D2),
; (-+)
5: sta A3
;
; A3

14

4
.
4 .
(1),

.
, .. 1
, D1 ,
- (4+3).
,
,
..

. -,
: ,
.
,
. -,
.
,
.
,
.
,
.

,
.

. -

.
.
, ,
, .
:
tmin - tmax;
W , ; t ^ ,
. ,
,
. . 3.
15

OS

. 3. -

-, .
, ,
. ( 2 - 5
. 3)
. , 4, 5
, .
(
1 ) 6. ,
,

.
( 1 )
( 1)
,
1. ( 2-5
) (
"" - "").

( ).

(. 2).
(),
, .

. Intel
8080 5 :
Z - , Z = 1,
( ) ;
S - , S ,

;
- , = 1,
;
- , = 1,
;
- , = I,
.

.
,
, .
, ,
, .
17

.
1:
ml:

add ; (+)
;
2: jmp A1
; 1
: . . . . ;
ml 5
. 2 1,
,
1 (
).
2:
ml:

add ; (-*)
;
2:
} 2
; 2,
; =/
:
jZ
A3
; A3,
; Z= 1
4: . . . . ;
ml 5
. 2 2,
C-L (-0), 2
, ,
. Z
4 ,

. , 2
, ,
: 2, A3
4.
,
,
. , ,
,
, ,
,
18


.

, .
, , -
(. 2). -
, (16 ),

.
, .
.
.
1.2.
(. 2)
- 8,
.
. D
, , :
D=D7D6D5D4D3D2D,Do .
D
,
, .
, , ,
..,
.
.
D, 2
, 0 - 255
(28-1).
(0 - 255), ( - 01111111, Ob ) (hex)
(0x00 - Oxff, Ox - hex-). hex-
16
6 , , , d, e, f.
hex-,
. hex-
, hex.
- ( bed) .
bed- , -

19


bed-.
bed- - 99.

. D 7 ,
7 D0-D6.B
"+" , "-"
.

.

. , ..
1
(//VF(D6D5D4D3D2D1Do)+l) .
1
. (-128) (+127).
,

.
. 1.
1
bcd-
hex

( (

( (
)

)
)
)
ObOlOllOQl

89

0x59

59

1011001

217

0xd9

-39

1001011

75

0x4b

+ 75

00000

131

0x83



83

+ 89

-125

,
-
.
20

1 2 :
01011001+11011001=00110010 Z=0, S=0, C=l, =1, =0.
(89+217 0x59+0xd9) : 50
(0x32), =1 ,

, 9 (2s=256) .
((+89)+(-39)) :
+50, ,
.
3 4

01001011 + 10000011=11001 Z=0, S=l, =0, =0, =0.


(75+131 04+083) : 206
(), =0 ,
, 5=/
D7.
((+75)+(-125)) :
- 50, 5=7, D7,
.
,
. ,
() .

,
. , add
(8) (8=8+8)
. adc

(8=8+8+) .

,
, .
.
,
, ,
.

21

, DE
( );
HL.
ml: mov , ; 1
; (8-=8),
2: add
E
; (8=8+8)
; ,
: mov L, ;
; L (L8-A8),
4: mov , ; 1
; (8~8),
{:
; ,
5: adc
D ; ,
;
; , (A8^A8+D8+C),
: mov H, ;
; (8=8).
,
, .
D
, D,
. ,
. ,
" " ana
(7=7&7, 6=6&6, . . .
0=0&0), S, Z, ,
- (===0), .

(
), ( ).
: =7, - 0 .
,
.
,
2, -
2. , ,
, .. ()
.
22


. ,
.

,
.
, , ASCII. ASCII
,
. , '1
ASCII- 0x41, '' - ASCII- 0x6b,
'2* - ASCII- 0x32 ..
ASCII ,
.
, ,
.
,

. ,
,
.
,
. ,

.
-
.
- ,
.
1.3.
()
:
(RAM)
(ROM). (. 2)
,
16 .

.
-
.

,
. 23

,
16- ,
.


. 2 16
(64 ).
(RAM)
.
( * RAM RAM >
)
.
. RAM
, .
RAM
, ,
. RAM
.

, .. RAM - .
, ,
, .
-
.
, . RAM,
, ,

- ROM.
ROM - , ..
.
.

ROM. ROM
. ROM
,
, ROM,
(
).
, ROM
, -

. ROM ,
24

, - ,
.
RAM ROM
.
, , ROM
. , , ROM
BIOS -
, RAM
(, hard-).
RAM
BIOS .
,
, , ,
, .
ROM
RAM.

, , ROM
RAM .
RAM ROM
.
:
(reset), ,
, .

,
.
, , ROM.
, ROM ,
, RAM -
.
,
.
.

.
, ,
.

:
, , , .
:
- , - .
25

- .
. :
mvi By D8 D8 (38=08),
; sui D8
D8 (A8=A8-D8).
.

, .
,
.
()
: , sta A16
16
(8-(16)).
.
-
,
. - ,
,
.
,
.
,
.
( ). : DE
, DE (A8=M(DE)); ana M
,
HL (A8=(A8)&M(HL)).
Intel 8080
HL (H - , L -
). , -, -
; , -,
,
.

.
,
( ) .

.

26

, Ixi HL, DLDH (DJ3


DH8) L (L8 = DL8, H8 = 8),
, inx HL
HL, (HL=HL+1).
- , ,
.
. ,
- ,
RAM .
RAM
- (SP) (. 2).
, ,

: " - ".
:
(SP) ,
(SP) .

: ,
, - , .. ,

,
, .
-
,

.
Intel 8080 .
:
ml: push ; B8-+RAM(SP-1), C8-+RAM(SP~2), SP=SP-2
m2: push DE ; D8-*RAM(SP~3), E8-+RAM(SP-4), SP^SP-4
; ,
; , , D,
; ; .
: pop DE
; RAM(SP-4)-+E8, RAM(SP-3)->D8, SP=SP-2
m4: pop
; RAM(SP-2)-+C8, RAM(SP-1)-+B8, SP^SP

.

27


(SP) .
SP RAM,

.
,
. ,
RAM, ,
.

.
1.4.
1.1 ,
,
, -
, ROM
.
,
,

.
-

,
.
.
.
1 ( ):
16 ( ),
, 1,
2.
1. , 16


, , .
2. 16
, .

.
:
- , 28

, HL ,

.
ml:
2:
:
4:
5:
:
ml:
8:

Ixi HL, Al; HL,


mvi , 0x10 ; ( ),
xra A
; (8=0),
mov , ; (8-8=0),
addM
; (A8=A8+M(HL)),
jnC 8
; 8, ,
inr ; 1 ( 1),
inx HL
; HL
; ,
9: dcr ;
; ,
mlO.jnZmS
; 5, ,
mil: sta A2
; ,
ml2: mov , ; ,
!3: sta (A2+1) ; ,
ml4:. . . .
ml-m4 ( )
; 5-10 , 16 ; mll-ml3
.
2 ( ):
1 :
.
,
, ,
. .
, HL 1,

.
ml:
2:
:
4:
5:
:
7:

Ixi HL, Al
; HL,
mvi , 0x10 ; ( ),

; (8-0),
mov , ; (8=8),
addM
; (A8=A8+M(HL)),
JC mil
; mil, 1,
inx HL
; HL
; ,
29

m8: dcr

;
; ,
9: jnZ m4
; 4, ,
mlO: jmp ml2
; ml2
; ,
ml I: movA, ;
; ,
ml2: sta 2
; ,
!3:
. . . .
2 ,
ml2, .

.
: "call A16" - "ret" -
.
, ,
.

.

.
, ,
.
:

,
;

,
;

,
.
, ,
,
.
, ,

.
,
.
.
, 30


.
,
:
,
,
.
.
"call A16"

16
, "ret" -
. -


.
,
.
(ret)
.
.
:
ml
2: callAsbl ; Asbl
; ,

;
; ,
Asbl: push PSW; ,
Asb2: push ; ,
Asb3: push HL ; HL,
. . . . ; ,
Asb4: pop HL ; HL,
Asb5' pop ; ,
Asb6' pop PSW ;
; ,
Asbl: ret ;
; ;
31

2
,
AsbL
ret
.

,
, , HL.

-
.

.
.
1.5. -

- .


. ,
,
- (. 1).
,
,
, ,
, , ,
() . -
,
. :
-, - , -
( DMA).

.
- -

,
. (. 2)
,

. (8) 32


: "in 8" - 8
, "out A8" -
8.

- .
.

.

.

.
,
,
. ,

.
:
,
,

.
-
,
,
, ,

.

,
.

(interrupt), - -
.
,
,
,
, .
-

33

;
, .

: INT,
-,
INTA,
.
,
("di") ("ei")
. "di" ,
INT .
"ei"
INT .
,
IN T,
,
INTA.
,
.
-
"call 16", 16 -
,
INT. ,
,

.
"ret",
. ,

.

"ei" "di".

,
. -,

, -,
, .
,
[1].

,
, , 34

INT
.

[1],
.
,
,
-.
- ,

,
,
, , ,
.
-
.

, ,
:

.
,
.
-
DMA.
-
.
DMA
DMA [1],
, , . DMA, ,
.
DMA
, .
DMA :
,
. , DMA
,
.
DMA

DMA. DMA
. , 35

DMA, ,
.
DMA :

DMA
;

,
,
DMA ;

, ,

,
;

DMA
,
.
DMA ,
,
. ,

,
.
-
.

, -

.
- ,


. ,
-,
,
, , ..


.

.
- ,
.
36

2. AVR
,
.

, .
,
, .
, ,
> ,
.

AVR ATMEL.
,
,
.

, AVR
8- .

- ,

.
, AVR
" ".
16- 32-
, ,
.. ,
,
8- .
,
.
, -
, ,
, ,
(
, ,
..).

,

.
37


AVR, ATMEL,

AT90S8535.
AVR,
.
AVR,

. AVR

.
2.1. AVR
ATMEL RISC -
. AVR
(AT90S1200, AT90S2313)
, megaAVR
, -
. AVR
, , ,
, (,
, -,
, .)
, ..
.

AVR
.


.
AVR
,

1.


.
, , ,
,
.
38

AVR
32
:
(FLASH), (RAM),
(EEPROM). FLASH EEPROM
, ,
. RAM - .

,
. 32
-.
- 2 , - 1 .


- -.
,
.
-,
.
, ,
.
,
-
.
.
AVR

. AVR
AT90S8535 .
2.2. AT90S8535
AT90S8535 (. 4) 118
8- - (),
(FLASH) 8 ,
(EEPROM) 0,5 (
), (RAM) 0,5 , 32
, 4
-, SPI,
UART,

, ,
, .
39

- 7

- 7

t t f t t t t ?
0-7

PD0-PD7

. 4. AT90S8535
40

(. 4)

.
1, .
, . 4,

.

.
.
AVR
,
. , . 4,
, ,
-,
SREG.

32, - 1.
: ,
26 - 31
X, Y Z .
- FLASH, RAM
EEPROM,
, ,
.
.


-,

.

(sleep mode) .
idle ,
,
.
power-down ,
, ,
,
, RE
SET.
RESET.
power-save power-down
41

2,

.
(. 4)
,
ATMEL. (.4) :
VCC GND () - ;
AVCC, AGND ( ), AREF -
;
RESET - (
50 ),
;
XTAL1 XTAL2 -
(
),
2 -
6 7;
0-7, 0-7, 0-7, PD0-PD7 - 32 -,
4 (PORTA, PORTB, PORTC,
PORTD).
PORTA, PORTB, PORTC, PORTD
-
. PORTA:
.
PORTB: 1 - 1 0 1
, 2 - AIN0 AIN1 ,
- SPI (PB4 SS, PB5 - MOSI, PB6 - MISO, PB7 - SCK).
PORTC: PC6 7 - 2.
PORTD: PD0 PD1 - RXD TXD
UART , PD2 PD3
- INTO INT1, PD4-PD7 - 1,
1 A, ICP, OC2 1 2.

42

2.3. AT90S8535
, FLASH, RAM, EEPROM, (. 5).

$000

$000
!

$01F
$020

FLASH
(4Kxt6)

$000

EEPROM
(0,5 8)

-
$05F

$060

$1FF

RAM
0,5 8)

$25F

$FFF

. 5. AT90S8535
FLASH -
,
. FLASH

. ,
(.
1). FLASH ,
"lpm"
Z.
FLASH 8
, , -

43

4 $000 - $FFF\

,
1000. 16- , ,
, - 1 8 .
EEPROM
0,5 $000 - $ IFF
.
EEPROM
. -
( 1) , ,
.
.

32 $000 $01F, 64 - $020 - $05F , ,
RAM 0,5 $060 - $25F.

RAM
. ,
RAM $026,
- $06 ADCSR.

.
sts k, Rr Ids Rd, (. 4), - $000$25F, Rr Rd .
X, Y, Z.
: X - r27-r26, Y - r29-r28, Z - 31. (
SPH-SPL -),

RAMEND, -
$25F.
FLASH.
:
(, mov r2, 0 - 0
2) (, mov

$,

44

r2, temp, temp - ).


- in, out (, out SPL,
16 - 16 - SPL)
, , (
- ).

,
. ,
, . ,

.
-
.

AVR
.
-,
, .
-
.

,
, .
, ,

.
-
.

45

3.
AT90S8535
,
,
.

,
. ,

, ,
.

,
.
, ,
.


.
AT90S8535
-
, ,
.
-
.

AT90S8535, 4.
3.1. -
, 32 (. 4), 4 (, , , D).

-,
.
, .
DDRA,
- $1, RAM $03
, -

46

: 0 - , 1 - . DDRA* (DDA0 - DDA7)


- ,
DDRA - .
,
DDRA
- .
1:
ml: ldirl6, ObOOOllllO ; 16 ,
; ,
2: out DDRA, 16
; 16 DDRA.
DDRA 7, 6,
5, , 4, , 2, 1 -
.
PINA ( - $19, RAM - $039) (in rl6,
PINA - PORTA)
,
- (, 5
PINA5 ).
PINA .
PORTA ( -
- $1, - $03) , ,

- (, PORTA4 - 4).
PORTA , .
2:
: ldirl6, ObOWlOWl ; 16 ,
; ,
4: out PORTA, r!6
; !6 PORTA,
5: in 15, PINA
; PINA 16.
, 1, 4-1, -0,
2-1, 1~0 ,

,
.inc.
(, "8535def inc")
.
.

47

, 4 .
( 5) ,
, ; ,
,
.

20 . ,
,
(pull-up),
. , DDA7=0 ( )
PORTA7=:l
7 .
, ,
.
7
. PORTA7==0
.
-
,
.
: -
.

, -:
-
. ,
-.

.
-

. ,
-
.

.
3.2. SPI
SPI -
-
SCK ( - 7), MOSI
( 5), MISO (
48

6), SS ( 4).
(master) (slave).
, , . 6.

FLASH EEPROM.
SPI-master .
8- MOSI,
, SCK
MISO 8- ,
SCK. 4
(DDB4=1), SS , 4
. 4 (DDB4=0), SS=1
SPI-master. SS=0,
,
SPI-slave .
master |
|
1

8-

i

]I

MISO I

| slave
PB6

PB6

PB5

MOSI |

1
|PB7

1 MISO

1 |

1
1
I MOSI

SCK 1

PB7|
1 sc*(

ss |PB4

P B 4 | ss

I
|
i_

!
|
i

. 6. SPI
SPI-slave SCK
8- ,
MOSI. SCK
MISO. 4
. SS=0 SPI-slave, SS=l,
.
SPI-master : MISO , MOSI - , SCK - , SS - (
), SPI-slave: MISO - , MOSI - ,
SCK - , SS - ( -

49

). SPI-master SPI-slave
(. 6), SCK
, 8 -master
-slave . MOSI - MOSI
SPI-master SPI-slave, MISO - MISO
.
SPI
-: - SPDR, SPCR, - SPSR. SPDR SPCR
, , SPSR .
, ,
, ,
-.
, .
,
.
1 ,
- .

;
, ,
,
.

. ,
SPI,
.
SPDR ,
. SPCR 8
( ).
SPCR
| SPIE | SPE

| DORP | MSTR \ CPOL | CPHA j SPR1 | SPRO [

SPIE - SPI, 0 .
SPE - ; 0 SPI,
1 .
DORD - 1 , 0 .
MSTR - I SPI-master, 0 - SPI-slave.
4 SPCR SCK:
50

CPOL - SCK
, .. 0
.
- 0
SCK , 1 -
.
SPR1 SPR0 SCK;

:
00 - 4,
01 ~ 16,
10 - 64,
11 - 128.
SPSR 2 . SPIF ( 7) , WCOL ( 6) - . SPIF
1 SPImaster SS. SPIF SPI_STC (
$00), SPIE=1 ( SPCR)
I SREG*.

SPISTC WCOL.
SPDR
SPI ( )
SPIF SPSR
SPDR.
SPCR
, SPDR
SPI-master . SPImaster (. 6) MOSI , MISO
SPI-slave SCK 8 ,
. SCK SPIslave (. 6) MOSI
SPDR MISO.
,
,
SPISTC.
SPI
. , SPDR,
,
. SPIE
SPISTC
" SREG

51

-
SPI. SPI-master

, .
, SPI
SPDR ,
, .
SPI-master SPDR.

SPCR.
SPI ,
.
SPI 5.
3.3. UART
UART
- D : - RxD (
PD0) - TxD (
PD1).

(
,
, 58051 [1] RS-232C).
- 8 9 , - 2400 /,
(, 4800, 9600, 14400
..).
UART 4
-: UBR - , UCR -
, USR - , UBRR - .
, .

- .
.
RxD TxD
.
UDR
; UDR ,
,
.
UDR,
,
.
52

UCR 8
.
UCR
[RXCIEJ TXCIE| UDRIE j RXEN

TXEN

CHR9 \ RXBjTj TXB8 |

RXCIE -
( UARTJRXC $00).
TXCIE -
( UARTJTXC
$00d).
UDRIE -
UDR , ..
UART,

( UART_DRE $00).
RXEN - , .
TXEN - ,
.
CHR9 - 9- .
RXB8 - 9- ( 8).
8 - 9- ( 8).
UCR
, ~
. , ,
.
USR
.
USR
[ RXC j

UDRE

FE

OR

- j

RXC - ;
UDR
UARTJRXC, RXCIE ( UCR) I (
SREG) .
UDR, .. RXC
UDR
.
53

- ; RXC
UARTTXC.

" 1" .
UDRE - UDR
( ); RXC
UARTDRE.
UDR,
.
FE - ; , ,
.
.
OR - ; ,
UDR,
. ,
UDR.
UBRR .
BAUD

BAUD =

,
16(UBRR + 1)

f- - ,
UBRR - ( $00 - $FF).

( ,
, 1 %).
, UART
UBRR,

UCR. USR
.
UART
UDR.
3.4.
3 -,
. 0 2 8-
, 1 16- .
.

( 1 1024)
. . , 2 54

,
.
32,768 ,
2 1 .

-.
TIMSK TIFR -
.
.

-
. TIMSK TIFR .
TIMSK , TIFR
, .

.
.
TIMSK
OCIE2 | TOIE2 | 1 OCIE1A | OCIE1B

TOIE1 | - j TOIE0 1

TIFR
[ OCF2 | TOV2 |

ICF1 ~ OCF1A j OCF1B | TOV1 | -

TOV0 1

, 6 (TOIE2 - TOV2)
2.
TOIE2 ,
2
TOV2, T I M 2 0 V F (
$004), .
TIFR
.
TIMSK TIFR.
3.4.1.
0 8-
TOIE0
TOV0 TIMSK TIFR. , 0 -

55

TCCRO TCNTO -.
TOV0 , ,
TIM0_OVF $009. TCCR0
, TCNT0 ,
, .
TCCR0 CS02, CS01,
CS00. 0:
000 - , .
001 - (
), fm.
010 - fn/8.
011 - fTH/64.
100 - ,/256.
101 - ^/1024.
110 - , (
PB0), .
111 - (PB0), .
TCNT0
,
,

. 0
TOV0.
0:
ml: clr rl
; 1 ( 1=0),
2: out TCCRO, rl; rl (0)
; TCCR0,
: out TCNTO, rl; rl (0)
; TCNT0,
4: Idi 16,1
; 16 1,
5: out TIMSK, 16
; TIMSK
; 0,
: Idi 16, 3
; 16 0,
ml: out TCCRO, rl6
; 0,
ml- 0 (2 - , - ). 4,
5 0. , ml
0. ml
: fmx/64 , 3, 256 56

TOV0. , 64*256=16384
.
3.4.2. 1
1 16- ,
4 ,
- ()
0.
,
, TIMSK TIFR.
, 1
10 -.
1 TOV1 (
TOV0),
TIMl_OVF $008. 1
,
OCR1 OCR IB, (Compare A, Com
pare ).
OCF1A OCF1B
TIFR
, .
- TIM1COMPA $006,
- 11_ $007.
1 -
ICF1. ICP (
- PD6) ,
ICR1
ICF1 TIFR
11_ $005.
-
, PD6.
ICR1
16- (ICR1L -
, ICR1H - ).
ICR1
( ICR1L)
- ( ICR1H) \
16-

.
TEMP.
57


.
TCCR1A
TCCR1B.
TCCR1
|COMlAl|COMlA0lCQMlBl|CQMlB0|

- ( - \ PWM11 | PWM10|


D : 1 (
PD5), 1 ( PD4) ,
COM 1A1, 1 , COMIBI, 10
TCCR1A. Compare
A, Compare 1X1,
1X0 (X - , ) :
00 - IX , D
.
01 - IX .
10 - IX .
11 - IX .
IX

TIMSK,
. ,
.
PWM11, PWM10 TCCR1A
1 :
00 - (
).
01 - 8- .
10 - 9- ,
11 - 10- .
.


TEMP,
TEMP. :
( TEMP),

TEMP.
.
58

TCCR1B

1 ICNC1 1 ICES1 | - 1 -

1 |

CS12

CS11 1 CS10 1

ICNC1 ICES1 TCCR1B


1 "" (capture). ICNC1
ICP.
""
ICP.
, ICP 4
.
. ICES1
ICP, -
, - .
1
.
,

($0000). CS12, CS11, CS10
1:
000 - , .
001 - (
), -
im.
010 - fT/8.
011 - fTH/64.
100 - fT/256.
101 - fTH/1024.
110 - , 1 (
1), .
111- Tl (PB1), .
(000)
, 0.

.
ICR1, I 16 : TCNT1,
A OCR1A,
OCR1B.
,
( L - , - ).
, , 59

,
.
TCNT1L TCNT1H
,
. TCNT1
,
. OCR1A OCR IB (no 2 )
.
,
.
( PWM11,
PWM10), 1 .
$0000
, ( 8 - $00ff, 9- - $01ff, 10- $03ff).
, , ..

,
(8 - 510, 9 - 1022, 10 - 2046).

(CS12, CS11,CS10) - 001, ..
.
OCR1A
OCR1B,
1 (PD5), IB (PD4) , , 1

.
11, 10 (X ~
, ) TCCR1A
:
00, 01 - , IX
.
10 - ,

.
11 - ,

.
TOV1 ,
$0000.
.
60

, 1, 16- ,
4 ,

.
1 0.
3.4.3. 2
2 8- ,
: TOV2, OCF2,
8- .

: TIM2_OVF
$004, 2_ $003.
2 ,
.
2 4
-: TCCR2,
TCNT2,
OCR2, ASSR. 2
1 .
TCCR2,
, 7 .
TCCR2
PWM2

21

201 2 | CS22 | CS21 1 CS20

PWM2 . 0 -
, 1 - 2
.
21, 20
2 (
- PD7). 2
1. 2 2
:
00 - 2 , PD7 D
.
01 - 2 .
10 - 2 .
11 - 2 .
2
TIMSK,
.
61

2,
.
2 2 .

,

($00).
CS22, CS21, CS20
:
000 - , .
001 - (
),
- fBX.
010 - fBX/8.
0 1 1 - fBX/32.
100 - fBX/64.
101 - fBX/128.
110 - fBX/256.
111 - fBX/1024.
(000)
, .
TCNT2 OCR2 ,
1. 2 (PD7)
.
ASSR 2
,

. (
6) ( 7)
. ,
32,768 .
ASSR
1

1 -

1 AS2 1 TCN2UB | OCR2UB | TCR2UB [

AS2 - . 0
. 1

6, 7.
TCCR2, TCNT2,
62

0CR2.
TCN2UB, OCR2UB, TCR2UB.

ATMEL.
2 1
8- ,
02 (PD7)
510, OCR2.
2 .
3.5.
,
AIN0 (
- 2) AIN1 (
).
"" 1
ANA_COMP $010.

ACSR, 6
,
.

ACD

ACSR
ACQ | ACI J ACIE | ACIC \ ACIS1 | ACISo"

ACD - , 1 .

ACIE.
- .
ACI - 1,
ACIS1, ACIS0.
ACIE ,
.
ACIE - .
ACIC - "" 1.
1 1
1.
ACIS1, ACIS0 -
:
00 - ,
01 - ,
10 - ,
63

11 - .
ACSR
,
. , SBI
CBI ACSR ACI.
3.6. - ()
10
, - 2
, 65 - 260
.
10- 8
( -
) 0 (AGND) (AREF).
(AGND, AVCC)
(. 4),
AVCC VCC
0,3 . 2
AVCC. $000
, S3FF ,
, .
,
, MUX2, MUX1,
MUX0 ADMUX.
ADMUX
,
.
- ,
, .


.
ADIF ADC
$00 10- ADCL
( 8 ), ADCH ( 2 ).
ADC
(. . 57).
, 50 200 , .
13
100
130 .
64

ADMUX, ADCH, ADCL,


ADCSR, .
ADCSR
ADENl ADSC| ADFR I ADIF [ ADIE | ADPS2 | APPSlj APPS20J
ADEN - , 0 - , 1 - .
ADSC - ,
,
- .
ADFR - , 1 - , 0 -
.
ADIF - ,
.
1 .
ADIE - , 1 .
ADPS2, ADPS1, ADPS20 - ,

:
000 - 2,
001 - 2,
010 - 4,
011 8,
100 - 16,
101 - 32,
110 - 64,
111 - 128.

,
"idle".

.
ATMEL.


,

.

65

3.7. EEPROM
EEPROM 4
-: EECR,
EEDR, EEARH,
EEARL. 4
.
EEPROM
EERDY SOOf.
EEPROM EEDR
, EEARH, EEARL.
EECR.
EECR
l - l - l - l - l

EERIE | EEMWE 1 EEWE j EERE [

EERIE - EEPROM,
EEWE.
EEMWE - EEPROM, EEWE
EEPROM EEDR ,
.
EEWE - .
EERE - ,
EEPROM EEDR.

.
ATMEL.
3.8.
17
-
$000 $010.
, $000
.
:
$000

rjmp RESET

$001

rjmp EXT__INT0

; IRQ0 Handler

$002

rjmp EXT_INT1

; IRQ1 Handler

$003

rjmp TIM2_COMP ; Timer2 Compare Handler

66

; Reset Handler

$004

rjmp TIM2__OVF

$005

rjmp TIM1_CAPT ; T i m e r l C a p t u r e

$006

rjmp TIM1_C0MPA

; T i m e r l CompareA H a n d l e r

$007

rjmp TIM1_C0MPB

; T i m e r l CompareB H a n d l e r

$008

rjmp TIM1_0VF

; Timerl Overflow

Handler

$009

rjmp TIM0_OVF

; TimerO O v e r f l o w

Handler

$00a

rjmp SPI_STC

; Timer2 O v e r f l o w

; SPI T r a n s f e r
;

Handler

Handler

Complete

Handler

$00b

rjmp UART_RXC

; UART RX C o m p l e t e

$00c

rjmp UART_DRE

; UDR Empty H a n d l e r

$00d

rjmp UART_TXC

; UART TX C o m p l e t e

$00e

rjmp ADC

; ADC C o m p l e t e
;

$00f

rjmp EE_RDY

$010

rjmp ANA_COMP

Handler

Handler

Interrupt

Handler

; EEPROM Ready H a n d l e r
; Analog Comparator

Handler


,

. $003 - $010
,

.
RESET $000
.
, ..
. RESET
$000
:

, RESET
50 ,
RESET .
MCUSR EXTRF ( 1), PORF (
0) . EXTRF
, PORF
67

.
,
.
00,
- 10, - 01, 11.

RESET. -,
I SREG
. -,
(
).

( , ). ,
I, ,
,
.
"reti", ( I)
( ).
( )
,
( I)
.
SREG,
, -.
, SREG -
,
.
,


.
SREG

| I | T ! H | S | V | N | Z | C |
I - ,

.
- ,
BLD, BST.
68

- ,

.
S - , mod 2 N V.
V - .
N -
.
Z - .
- .
- 2
SPL, SPH -.
.
RAMEND,
.

.
INTO (
PD2) INT1 ( PD3)
GIFR, GIMSK
MCUCR -. GIMSK INT1
( 7) INTO ( 6) ,
GIFR INTF1 ( 7) INTFO ( 6)
,
.
, ,
ISC01, ISC00 ISCll, ISC10 MCUCR.
sleep,

.
MCUCR
1 -

1 SE

| SMI | SMO | ISCll | ISC10 \ ISC01 I ISCOO I

SE - sleep; ,
sleep "sleep".
SMI SMO sleep:
00 - idle,
01 - ,
10 - power-down,
11 - power save.
4
INTF1, INTF0.

69

, ISCX1, ISCX0 (X - 0 1)
:
00 -
,
01 - ,.
10 -
,
11 -
.
, PD2 PD3 ,

.
(Watchdog Timer)
.
WDTCR,
( 15 2 )
RESET.
,
RESET.

-
.
WDTCR,
.
WDTCR
-.

WDTOE J WDE

WDP2 ] WPP1 PwDPO [

WDTOE - .
WDE - ; 1 - ,
0 - .
WDP2, WDP1, WDP0 -
RESET . 000 - (
15 ), 1 1 1 - ( 2 ).
(/,
WDE) : WDTOE, WDE
;
4 WDE
(0 - , 1 - ). 4 WDTOE
.
70

,
ATMEL.
-

. (,
, , ..)
.
- ,
.
,
, ..
,

.
,

. AVR
, , ,
,
. ,
,
,
-.

.
.


.
,
. ,

,
.
.
AVR
, -
.
:
-

;
71

( I
SREG) -

;
-
I
( reti)
( ,

I, );
() -

;
-
/ ;

- -
/ .


( -
):
1.
( 100 ,
).
2. , ,
,
,
.
3. -
.
4.
/
.
5. SPI
.

72

6. UART -

.
7.
,
(,
..).
,
,
.
,

-.
,
, - ,

.

.

.
,
,
.

73

4. AVR

- .

.

ATMEL, , AVR Studio.
AVR Studio
,
,
.
,
,
,
.
AT90S8535 118
,
, .
, , :
(,
Id r24, X+ R24
X);
(, cbr r 18, 2
( 0) 1 R18);
,
- (, sbi PORTC, PC7
( 1) 7 PORTC);

SREG (, brtc label
label, ).

, .
()
, , M8535def.inc",
. ()
SREG ,
.

74

SREG
I

SREG ( ):
I - , (1)
(0) .
- , (
) .
- .
S - , mod 2 N V.
V - ( ).
N - ( 7
).
Z - .
- .
SREG
, , ,
.
4.1. AVR

, :
, -, .
.
:
Rd - , (
).
Rr - , (
).
- ( ), 0 255,

: 0x00 - Oxff $00 - $ff, -
: 000000000 01111111.
- (
), ,
.
X, Y, Z - (
X - R27,R26; Y - R29,R28; Z R30,R31).
- -.
75

b - 0 7 ( - 7, - 0).
PC - .
STACK - .
- (FLASH).

4.1.1.
2

add Rd, Rr

,
Rd <- Rd+Rr

HVNCZ

adc Rd, Rr

,
Rd - Rd+Rr+C

HVNCZ

(2 ,
R(d+l)Rd) ,
R(d+l)Rd <- R(d+l)Rd+K

SVNCZ

adiwRd,

sub Rd, Rr
subi Rd,
sbc Rd, Rr
sbci Rd,

sbiwRd,

,
Rd <- Rd-Rr
,
Rd +- Rd-K
,
Rd - Rd-Rr-C

,
Rd- Rd-K-C
(2 ,
R(d-H)Rd) ,
R(d+l)Rd+-R(d+l)Rd-K

HVNCZ

HVNCZ

d=(16-31)

SVNCZ

d=(24,26,28,30),
K=(0-63)

Rd Rd+1

VNZ

Idee Rd

Rd < Rd-1

VNZ

andi Rd,
or Rd, Rr
76

,
Rd +- Rd*K
. ,
Rd<-RdVRr

d=(16~31)

HVNCZ

,
Rd - Rd*Rr

d=(24,26,28,30),
K=(0-63)

HVNCZ

incRd

and Rd, Rr

VNZ
VNZ
VNZ

d=(16-31)

. 2

ori Rd,
eor Rd, Rr


, R d ^ R d V K

VNZ

Rcl-RdRr

(16-31)

VNZ

com Rd

,
Rd - $ff-Rd

VNZ

neg Rd

,
Rd *- $00-Rd

HVNCZ

asr Rd


, Rd(7)
,
Rd ,
<- Rd(0)

VNCZ

lsl Rd

,
Rd ,
Rd(0) < 0.
- Rd(7)

VNCZ

lsr Rd

,
Rd
,
Rd(7)<-0^arO-Rd(0)

VNCZ

rol Rd


, Rd
,
Rd(0) < ,
- Rd(7)

VNCZ

ror Rd


, Rd
,
Rd(7) ,
<- Rd(0)

VNCZ

77

. 2

tst Rd

Rd, Rr

Rd, Rr

cpi Rd,


Rd , Z
N
Rd,
V <-0

SVNZ

,

,
HVNCZ


Rd~Rr
,

,
HVNCZ


Rd-Rr-C
,

,
HVNCZ


Rd-K

d=(16-31)


RISC
.
:
add R3, R16 R3
R16, R3, R16
,
HVNCZ;
subi R21, $F0
R21 240 ( $F0),
R21,
HVNCZ (
R16-R31);
and R3, R4
() R3 R4, 78

R3, R4 ,
VNZ;
asr R0 2 R0,
. . R0,
7, 0
, VNZ .
AVR
. , megaAVR
.
,
. ,
. ,
, Rd Rr -
.
, SREG
. -
, , .
, ,
,
.

4.1.2.
3


,
Rd Rr

ldi Rd,

,
Rd<-K

Ids Rd, k

Rd
( k), Rd <- ()

sts k, Rr

Rr
( ), () <- Rr

in Rd, P


- Rd,
Rd<-P

mov Rd, Rr

d=(16-31)

79

out P, lb-


Rr - ,
P-Rr

push Rr


Rr ,
STACK <~ Rr

popRd

Rd
,
Rd STACK


X, Y, Z

Id Rd, X

Rd
,
X,
Rd - ()

Id Rd, -X

Rd
,
X,
X,
Rd*~03y(X-l),
X-X-l

Id Rd, X+

Rd
,

X,
X,
Rd-03y(X),
X<-X+l
J

st X, Rr


Rr ,
X,
() <- Rr

80

. 3

st -X, Rr


Rr ,
X,
X,
03y(X-l)<-Rr,
X -1

st X+, Rr


Rr ,
X,
X,
03y(X)+-Rr,
-+1

Id Rd, Y

Rd
,
Y,
Rd <- 03Y(Y)

Id Rd, -Y

Rd
,
Y,
Y,
Rd<-03y(Y-l),
Y-Y-l

Id Rd, Y+

Rd
,
Y,
Y,
Rd+-03Y(Y),
Y<-Y+l

ldd Rd, Y+k

Rd
,
Y ,
Rd <- (Y+k)

st Y,Rr

Rr
,
Y,
03Y(Y)- Rr

=(0-63)

81

. 3

st -Y, Rr


Rr ,
Y,
Y,
(-1)-Rr,
Y*-Y-l

st Y+, Rr


Rr ,
Y,
Y,
03Y(Y) 4- Rr,
Y<-Y+l

std Y+k, Rr


Rr ,
Y ,
(Y+k) - Rr

Id Rd, - Z

Rd
,
Z, -
Z
Rd-03Y(Z-1),
Z-Z-l

Id Rd, Z+

Rd
,
Z,
Z,
Rd<-03Y(Z),
Z<-Z+l

lddRd,Z-*k

Rd
,
Z ,
Rd <- 03Y(Z+k)

1 st Z, Rr

st ~Z, Rr

Rr I
,

Z,
03Y(Z) - Rr

1
Rr ,
Z,
Z,

03y(Z-l)*-Rr,
82

Z<-Z-l

=(0-63)

-(0-63)

. 3

st Z+, Rr

std Z+k, Rr

1pm


Rr ,

Z,
Z,
03Y(Z)^-Rr,
Z<-Z+l

Rr ,

- Z ,
(Z+k) - Rr
R0
FLASH ,

Z,
R 0 - PM(Z)

=(0 - 63)


:
(mov);

- (in, out);
( )
(Id, st) (pop, push).

R16-R31. ,

.

, ,
, "8535def.inc". ,
out $08, R16 out ACSR, R16 :
R16
.
,
,
,
- out.

- in. ,

. 83


in, out.
EEPROM
-
. Ipm R0
, (FLASH). FLASH
Z.
FLASH ,
Z ( 0) R0 (0 -
, 1 - ). FLASH Z,
1. 1 FLASH,
Z. FLASH
Z Z=2*^pec FLASH), 0
Z ,
FLASH R0.
4.1.3.
4

rjmpk

ijmp

rcall k

icall

PC k), PC ~ PC+l+k

Z, PC < Z
(
PC ),
STACK*- PC,
<- +1+

Z,
STACK*-PC, PC<-Z

ret

,
PC <- STACK

reti

,
PC STACK, I = 1

84

-2048 < < 2048

-2048<<2048

. 4

brbs b,

brbc b,

[ (
PC ), b
SREG , PC <
PC+1-fk, 8()==1
1 (
PC ), b
SREG , PC <+1 +, SREG(b)=0

-64<<63

-64<<63

breq

(
PC ), ,
PC <- +, Z=l

-64<<63

brnek

( PC ),
, PC < PC+1 +,
Z=0

-64<<63

brcc
(brio )


=0, PC <- +1+,
=0

brmi

N=1

|1

N=0

brvs

V=l

brvck

V=0

brge

S=l

brltk

, S=0

brhs

H=l

brhc

H=0

bits

1 T=l

brtck

brie

1=1

bridk

1 1=0

-64<k<63

-64<k<63

-64<k<63

-64<k<63

-64<k<63

-64<k<63

-64<k<63

85

. 4

1 ,

sbrs Rr, b

,
Rr ,
PC <- +2(3),
Rr(b) = 1

sbrc Rr, b

, b
Rr ,
PC *~ +2(3),
Rr(b) = 0

sbis P, b

, b
-
,
PC +2(3),
() = 1

cpse Rd, Rr

, Rd = Rr,
P C - +2(3),
Rd = Rr

= (0-31)


.

,
, ,
,
.
- (PC),
- ().
AVR
, (

).
.

. 86

rjmp , rcall 8535


,
4096 (8 ).
, ,
rjmp.
:
RO, R21
; RO, R21
breq inter
; , inter ( 63)
inter:

rjmp fin
fin: nop

; fin ( . . )
; R0-R21

"" ( )
.
rjmp rcall
.

4.1.4.
5

sbr Rd,
cbr Rd,

Rd

Rd

d = (16-31)

d = (16-31)

sbi P, b

b,
P(b)=l

= (0-31)

cbi P, b

b,
()=0

= (0-31)

bst Rr, b

b
Rr ,
<- Rr(b)

bid Rd, b

b
Rd ,
Rr(b) <-

swap Rd



Rd

87

. 5

serRd
clrRd
bsetb
bclr b

1
Rd,
Rd $ff
1
Rd,
R d - $00
b
SREG,
SREG(b) - 1
b
1 SREG,
SREG(b) - 0

d = (16-31)

VNZ
SREG(b)
SREG(b)

clc

< 0

sez

Z,

Z < 1

clz

Z,

Z 0

sen

N,

N < 1

cln

N,

N < 0

sev

V,

V < 1

civ

V,

V < 0

ses

S,

S < 1

els

S,

S * 0

seh

< 1

* 0

1 cUl
set
! clt
sei

cli

,
,
I,

I I,

< 1
< 0

I *- 1

I < 0


( ,
), 32 - (0-31)
SREG. I
88

( sei) (
cli) .
( )
:
bst R12, 4 ; 4 R12
bidR16, 0 ; 0 R16
sbr cbr Rd,
:
cbr R16, ; 7, 5, 2, 1 R16
sbr R17, $0f
4 RI7
sbi
- (0-31), , sbi PORTC,
0 PORTC.

4.1.5.
6

sleep

sleep

wdr


. sleep
(sleep mode)
, -
MCUCR . wdr

, .

89

4.2. AVR

.
AVR Studio. ,
.

.
.
,
, .
120 . ,
, .
,
, .
:
; []

,
,
.
(
):
[:]

[]
[/]
[:]

[]
[;]
;

(, ,
) .

.
.
.
(, )
.
.
,
, ..
, : .CSEG.
,
.
.CSEG, .DSEG, .ESEG
, , EEPROM (EEPROM),
( 90

.CSEG).

AVR. .ORG k
:
.CSEG
.ORG $120

more: cpi 19, $00
; ,
brne repADl
mov
rl7,rl8
; 7
Mr 17
brcs repADl
;, 7 0

.ORG $090
repADl: nop

(.CSEG);
more $120,
- . .ORG
$090 , , repADl,
$090.
.DB ( ), .DW ( )
EEPROM
.
, .
ORG
. DB DW
, :
.ESEG
const!:

. DB 02, 255, ObOlOWlOl, -128,

.CSEG
.ORG $380
led:. DW $063/, $4f5b, 6d66, a77d, $0000
91

(DB) EEPROM, EEPROM


, (02)
const 1. (DW)
, ($063f) led
.ORG $380.
.INCLUDE " " ( )
. : .INCLUDE
"8535def.inc"
.
,
DEF, EQU, SET.
.DEF ( ), .EQU (
), .SET ( )

. .EQU
, , .SET
.
.

ATMEL. :
.EQU MCUCR=$35

.EQU MCUSR:=S34 ;

.EQU PORF =0

.DEF XLr26

R26 XL

.DEF XH-r27

R27


MCUCR $35 (
53), , ,
($35),
(MCUCR). , out $35, 26 out MCUCR, XL
;
, - .
,
,
, ,
.. 92

,
.

.NOLIST ( ), .LIST ( ).

, .NOLIST
.LIST. ,
8535def.inc,

.
,
, .
- 4 , .. ,
4- .
; ,
.SET .EQU; (
-
); PC - .

, .
:
: + , - , * , / ;
: , ;
: & , && , |, ||, ! , ;
: = , != , <, <= , > , >= .
( )
, .
:
LOW(paee) - ,
() - ,
2() HIGH,
YTE3 () - ,
4() - ,
L\() - 0-15 ,
\^1() - 16-31 ,
() - 16-21 ,
2() - 2 (),
2() - 12().

93

:
Idi
out
Idi
out
Mi

rl6, LOW(RAMEND) ;RAMEND=0x025f, LOW(RAMEND)~0x5f


SPL, rl6

rl6, HIGH(RAMEND) ; HIGH(RAMEND) =0x02
SPH, r!6
;
rl6, (1OCIE1A)\(1TOIEO)
16
; ,
; 0 1
; ,
out TIMSK, !6
; 16 TIMSK.
,
, 0x11.
Ipm FLASH Z 1
, Z , FLASH (1 - , 0 -
). FLASH (, ledbcd),
FLASH :
Idi ZL, LOW (ledbcd*2)
FLASH eZ
Idi ZH, HIGH(ledbcd*2)
; 1 2
ipm
;
mov
rl,
; rl
inc ZL
; ( ZH)
Ipm
;
,

.

94

5.
,

, (
).
,
,
,
.

, , . -,
,
,
. -,
,
,
. -,

.

:
1. ,
,
.
2.
, , ,
,
.
3.

.
4.
, , .
5.
,
.
6. ,
.
-
95

( ,
, ..).


AVR Studio. ,
,
.
5.1. AVR

.
1.
4 , RAM
: $060, $061, $062, $063,
- load.
"".
SPI,

, , X.
SPI master
SCK (PB7), MOSI (PB5). MISO (PB6)
,
, , 4.
SRCR
: 001011100, SPIE
.
SPITC $00.
,
,
.
( )
.
; 1, ""
.NOLIST
.INCLUDE "8535def.inc"
.LIST
.DEFtemp = 16 temp 16
.CSEG
.ORG $000
rjmp init
reset
.ORG $00a
96

rjmp spite
.ORG $011
ink:

ldi temp, iow(RAMEND)


out SPL, temp
ldi temp, high(RAMEND)
out SPH, temp
; RAMEND
ldi temp, SfO
out DDRB, temp
; 4 PORTB
ldi temp,
out SPCR, temp ; SPI

;
start: clr XH
Idi XL, $60 ; X
Id temp, X+ ; temp X
out SPDR, temp ; SP1
sbi SPCR, SPIE ; SPI
sei
;
; ,
;
main: nop
rjmp main
;/ SP1
spite: cpi XL, $64
breq end
; ,
Id temp, X+ ; temp X
out SPDR, temp
; SPI
reti
;
;
end: sbi PORTB, PB4
; load
cbi SPCR, SPIE
; SPI
cbi PORTB, PB4 ; load
reti
;
4-

( start - 6 ), ( spite
- 5 ) ( spite, end - 6 ).
27 ,
.
97


start
. SPI
.
( main),
- .
"".
,
, RAM
X.
; 1, ""
.NOLIST
.INCLUDE "8535def.inc"
.LIST
.DEF temp = r 16 temp 16
.CSEG
.ORG $000
rjmp init
reset
.ORG $011
init:
Idi temp, low(RAMEND)
out SPL, temp
ldi temp, high(RAMEND)
out SPH, temp
; RAMEND
ldi temp,$f0
out DDRB, temp ; 4 PORTB
sbi PORTB, PB7
;
start: cli
;
clr XH
ldi XL, $60 ; X
byte: Id temp, + ; temp X
ldi 17, $08
;
bit:
sbrs temp, 7 ; , 7
cbi PORTB, PB5
; 5
sbrc temp, 7 ; , 7
sbi PORTB, PB5
; 5
cbi PORTB, PB7
; 7 ( SCK)
lsl temp
;
sbi PORTB, PB7
; 7 ( SCK)
98

dec rl 7
brpl bit

;
; bit,
;
cpi XL, S64 ;
brne byte
; ,
;
end: sbi PORTB, PB4
; load
nop
cbi PORTB, PB4
; load
sei
;
; ,

main: nop
rjmpmain

( bit - 9 ) 32 ,
( start - 3 ) ( end - 4
) - 1 , ( byte - 2
) - 4 , .. 303 .
, ,
, , ,
,
- .
2. ,
, 1, 2 , ;
8- ,
;
: $060, $061, $062, $063.

,
.
.
, ,
ADMUX. X.

99

; 2
.NOLIST
.INCLUDE "8535def.inc"
.LIST
.DEFtemp = rl6 ; temp 16
.CSEG
.ORG $000
rjmp init
; reset
.ORG $00e
rjmp adc
;
.ORG $011
init:
ldi temp, low(RAMEND)
out SPL, temp
ldi temp, high(RAMEND)
out SPH, temp
; RAMEND
clr temp
out DDRA, temp
;
ser temp
out PORTA, temp ;
;
ldi

temp,

out

ADCSR, temp

start: clr XH
ldi XL, $60 ; X
out ADMUX, ; 0
;
sbi ADCSR, ADSC ;
sbi ADCSR, ADIE;
sei
;
; ,

main: nop
rjmp main
;/
adc:
in r20, ADCL
; 20
in r21, ADCH
; 21
lsr 21
20
100

lsr

r21

;
;
; 8-
; X

20
st +, 20
cpi XL, $64
breq end
;
mov temp, XL
cbr temp, $f8
out ADMUX, temp ;
;
sbi ADCSR, ADSC
;
reti
;
end: cbi ADCSR, ADIE ;
reti
;

3. ,
8-
0,5 ,

.

0,5 . ( 1)
, - ( 2)
.

, , . 1 2
IntO
(PD2), Intl (PD3). , ,
2 PD2 ,
1 - PD3 .

D, , PD1.
8
0,5 - 1
- 1024, 3906 ($0f42) 1 .
TCCR1 ,
TCCR1B .
TCCR1B,
.
TCNT1H, TCNT1L. 101

: IntO ($001), Intl ($002), Timl_CompA ($006).


, 0,5

, - .
; 3
.NOLIST
.INCLUDE "8535def.inc"
.LIST
.DEFtemp = rl6 ; temp rl6
.CSEG
.ORG $000
rjmp init
; reset
rjmp restim
; (intO)
rjmp timon
; (intl)
.ORG $006
;
rjmp half
;
.ORG $011
init:
Idi temp, low(RAMEND)
out SPL, temp
Idi temp, high(RAMEND)
out SPH, temp
; RAMEND
ser temp
out DDRB, temp
;
out PORTD, temp
; D
clr temp
out PORTB, temp
; ()
out DDRD, temp
; D
sbi DDRD, PD1
; PD1 ()
out MCUCR, temp ;
Idi temp, $08
out TCCR1B, temp ; 1
;
Idi 18, $42
Idi rl9,$0f
out OCR1AH, rl9
out OCR1AL, rl8
; (3906)
Idi temp, $10
out TIMSK, temp
;
Idi temp, $c0
out GIMSK, temp
;
102

sei

; ,

main: nop
rjmp main
restim: clr r20
out PORTB, r20
()
cbi PORTD,PDl ;
out TCNT1H, r20
out TCNTlL,r20
; 1
stop:: in temp,TCCRlB
cbr temp, $07
out TCCR1B, temp ; 1
reti
;
timon: in temp, TCCR1B
sbr temp, $07
out TCCR1B, temp ; 1
reti
;
half: sbic PORTD, PD3
; , 1

1
rjmp stop
inc ir20
out PORTB, r20 ;
breq carry


reti
carry: sbi
rjmp

PORTD, P 01
;
; 1
stop


- .

AVR .

-
.
,
- .

103

5.2.

AT90S8535
, 1
. 3.

.
,
. ,

(1 - , 0 - ).
,

.

:
0,1 (, 215 (0xd7) - 21,5 ).
: tram=17,0 C, traax==22,0 C.

.
,
.
,
.


, . 7.
"

__

-> 1

_/1

-> 2

- PD2

. 7.
.
("
"). ,
"" , 104

.
.

, .
.
"",
"".
"", ""
.

, :
.
SPI ,
(. 8).
RG

/ /

D1

Out

HI/ /

CP

MOSI

Out

Load
CP

SCK

. 8.
-
D1-D3 In,
SC,
,
. MOSI SPI, 105

master, In D1,
SCK - SC .

,
.
SPI D3, - peD2 - D1.

Load, SPI .


. , ,
- ?
,
, - (- .
3 :
1 - 2 ). ,
, .

.
-
,
.
,
,
.
,
.
, 1 .
(
1-2 ),


.

tmin tmax .
, , ,

(--- ..).
( tj
t2),
. 1, tmaxi=23,0 C;
tmax2=21,0C; ^1=16,0 ; tmin2=18,0C.
106

,
0 - 8
. - 4 .

, : - 1, 1 - 2.

ADMUX.
,
32.

.
- : 7 -
, 6 - . ,
() - (
).
SPI
SPCR.
master,
, SCK .
,
- 16.
5 (MOSI), PB7 (SCK).
(Load) .

.
SPI

.

. FLASH,


FLASH. SPI
,
.

INTO.
MCUCR PD2
GIMSK.
1 2,
(, ).
PD2, 1 2
. , -
107

, - PD2
, (. 7)
1
0, .

: t=1024*256/4uc=65,536 .
,
16- ,
T=16*t=l,05 .
,
.

AT90S8535
. 9.

>

>

>

>i

-5*

cool
V

/
heat

REF
AREF

AT90S8535

1
2

5
7

MOSI I

I
1
SCK
Load

PD2

. 9.

, 1 .
108


.
(REF)

.

0,1-0,2 %.
6, 7
cool, heat ,
.

,
.
. 7, 8.


.

.
,
: ,
,
.

.
,
,
- . ""

0
1 .
, .
SPI

, . 3. ,
,

0. , 1%
.

"",
: , 0, SPI
109

.
, .
;
.NOLIST
.INCLUDE "8535def.inc"
.LIST
;
.DEF t e m p l a r 16
.DEF temph = rl7
.DEF saveF = r4
.DEF counT = rl8
.DEF rcnt = r!9
.EQU Mind = 0x100 ; RAM
.EQU Made - 0x090 ; RAM
.CSEG
;
.ORG $000
rjmp ink
; reset
rjmp key_cnt
; intO
.ORG $009
rjmp cycle ; 0
rjmp spistc
; SPI
.ORG $00e
rjmp adc_cmt
;
.ORG $011

ink:
Idi tempi, low(RAMEND)
Idi temph, high(RAMEND)
out SPH, temph
out SPL, tempi RAMEND
; -
Idi tempi, Obi 1000000
clr temph
out PORTA, temph
out DDRA, tempi
ser tempi
out PORTB, tempi
out DDRB, tempi
;
out PORTD, tempi
110

out DDRD, temph


; D
; INTO
Idi tempi, (1ISC01)|(0ISC00)
out MCUCR, tempi
; INTO
Idi tempi, (1INT0)
out GIMSK, tempi ; INTO

Idi tempi, (110)
out TIMSK, tempi
; SPI
idi tempi Obi 1011001
out SPCR, tempi
;
clr tempi
out ADMUX, tempi ;
Idi tempi, 000001
out ADCSR, tempi
sei
rcall

ind_pff

;
;

; ,

main: nop
rjmp main
indoff:
; SPI
clr tempi
Idi XL, low(Mind)
Idi XH, high(Mind) ; RAM SPI
st
X+, tempi
st
X+, tempi
st
X+, tempi
idi XL, low(Mind)
rcall
spi_stc
;
ret
;1NT0,
keycnt:

push tempi
push temph

push saveF
in saveF, SREG
; "", ""
in tempi, PINB
sbrs tempi, PB2
;
rjmp cnt_off
;
sbrs tempi, PB1
;
rjmp cnt_on
;
; 1,
key out:
;
out
SREG, saveF
pop
saveF
pop
temph
pop
tempi
reti
cnton:

tst rent
brne key_out
sbr
rent, 0x80 rent
Idi temph, 0x05
out
TCCRO, temph ;
clr
counT
;
out ADMUX, counT - ;
sbi
ADCSR, ADSC ; 1
cbi
PORTA, PA7
cbi
PORTA, PA6
rjmp key_out

cntoff:
;
tst
rent
breq key_out
clr
rent
; rent
clr
temph
out
TCCRO, temph ;
out
TCNTO, temph ;
clr
counT
;
cbi
PORTA, PA7

cbi
PORTA, PA6
waitspi:
cpi
XL, low(Mind) ;
breq cnt_end ,
sei
rjmp waitspi ;
cntend:
rcall
rjmp

ind_off
key out

;
cycle:
push saveF
in saveF, SREG
tst rent
;
breq cyc_out
cpi counT, 15
;
breq e y e d o
; 16
inc counT
;
rjmp cyc_out ; (<16)
eyedo:
clr counT
;
out ADMUX, counT ;
sbi
ADCSR, ADSC ; ,

cycout:
out
SREG, saveF
pop
saveF
reti

adeemt:
push tempi
push temph
push saveF
in saveF, SREG
tst rent
breq
adc_out

113

;
in tempi, ADCL
;
in temph, ADCH
;
isr temph
ror tempi
lsr temph
;
ror tempi
; 8-
in temph, ADMUX ; ?
tst temph
;
brne tmtr
; , PAl ( 2)
sbi ADMUX, ADMUXO PAl
sbi ADCSR, ADSC
;
sts Made, tempi
; ( 1)
rjmp adc_out

tmtr:
;
Ids temph, Made ; RAM
add
tempi, temph; PAl
ror
tempi
;
;
cpi tempi, 230 ;
brcs
thresh 1 ; , <
rcall
cool
;
rjmp bedt

thresh 1:
cpi tempi, 210 ;
brcc bedt
; , >
hresh2:
cpi tempi, 160 ;
brcc
thresh3 ; , >
rcall
cool
;
rjmp bedt

hresh3:
cpi tempi, 180 ;
brcs
bedt
; , <
rcall
offch ;
rjmp bedt
;
114

;
cool:
sbis
PINA, PA7
,
sbi
PORTA, PA7 ;
ret
;
;
heat:
sbis
PINA, PA6
,
sbi
PORTA, PA6 ;
ret
;

offch:
sbic
PINA, PA7
; ,
cbi
PORTA, PA7 ;
sbic
PINA, PA6
; ,
cbi
PORTA, PA6 ;
ret
;
bed
bedt:
clr
temph
;
hunst:

cpi
tempi, 100;
brcs
hunout
; SPI
subi
tempi, 100; 100
inc
temph
;
rjmp hunst
;
hunout:
; RAM SP1
rcall
codeind
decst:
clr
cpi
brcs
subi
inc
rjmp

temph
;
tempi, 10 ;
decout
; SPI
tempi, 10 ; 10
temph
;
decst ;

decout:
; RAM SPI
rcall
code ind
115

mov
rcall
rjmp

; RAM SPI
temph, 11;
code_ind ;
str_spi
; SPI

code
Idi
Idi
add
Ipm
st
ret

ind:
ZL, Iow(cdind*2) ;
ZH, high(cdind*2); FLASH
ZL, temph ; temph
; temph
-X,
RAM SPI
;

; SPI
strspi:
Idi XL, low(Mind)
Idi XH, high(Mind) ; RAM SPI
rcall
spi_stc
;
adcout:
;
out
SREG, saveF
pop
saveF
pop
tempi
reti
;
spistc:
push tempi
push temph
push saveF
in saveF, SREG
cpi XL, low(Mind+3) ;
breq
load
;
Id tempi, X+ ;
cpi XL, low(Mind+2) ;
brne skip
;
sbr
tempi, 0x80
;
skip:
out
SPDR, tempi;

116

spiout:
;
out
SREG, saveF
saveF
pop
pop
tempi
reti
load:
cbi
PORTB, PBO
nop
nop
nop
>
sbi
PORTB, PBO
rjmp spiout
;
.ORG 0x0800
cdind:
; ,
.dB 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f
;endof file
, AVR Stu
dio, . 5 - FLASH,
.
4 - hex-,
.
.LIST

.DEF tempi = rl 6
.DEF temph = rl7
.DEF saveF = r4
.DEF counT = rl8
.DEF rent = r 19
.EQU Mind = 0x100 ; RAM
.EQU Made = 0x090 ; RAM
.CSEG
;
.ORG $000
000000
rjmp init
; reset
000001 c035
rjmp
key_cnt
; intO
.ORG $009
; 0
000009 c055
rjmp cycle
; SPI
00000a c0b2
rjmp spi_stc

117

.ORG $00e
OOOOOe c05e
rjmp adc_cmt

.ORG $011
;
000011 e50f
init:
ldi tempi, low(RAMEND)
ldi
temph, high(RAMEND)
000012 012
out
SPH, temph
000013 bfle
out SPL, tempi
;
000014 bfOd
RAMEND
; -
000015 ec00
ldi tempi, 0b 11000000
000016 2711
clr temph

000017 bblb

out

PORTA, temph

000018 bbOa

out

DDRA, tempi

000019 efOf
sertempl
00001 a bb08
out PORTB, tempi
00001 b bb07
out DDRB, tempi

00001 bb02
out PORTD, tempi
00001 d bb 11
out
DDRD, temph
; D
; INTO
0000le e002
ldi tempi, (1ISC01)|(0ISC00)
00001 f 5
out MCUCR, tempi
; INTO
000020 e400
ldi
tempi, (1 I N T O )
000021
out
GIMSK, tempi
; INTO
; 0
000022 e001
ldi
tempi, (1 T O I E 0 )
000023 bfl)9
out
TIMSK, tempi
; SPI
000024 ed09
ldi
tempi, Obi 1011001
000025 b90d
out SPCR, tempi
;
000026 2700
clr
tempi
000027 b907
out
ADMUX, tempi ;
000028 e80d
ldi
tempi, 0b 10001101

000029 b906

out

00002a 9478
00002b d002

sei
rcall

ADCSR, tempi

ind_off

;
;

; ,

00002 0000
main: nop
00002d cffe
rjmp
main
ind_off:
; SPI
000022700
clr tempi
118

O0002f eOaO
000030 eOb 1
000031 930d
000032 930d
000033 930d
000034 eOaO
000035 d087
000036 9508

Idi XL, low(Mind)


Idi XH, high(Mind) ; RAM SPI
st X+, tempi
st X+, tempi
st X+, tempi
idi XL, iow(Mind);
rcall
spi_stc
;
ret

;INT0,
key_cnt:
;
000037 930f
push tempi
000038 93If
push temph
000039 924f
push saveF
00003a b64f
in
saveF, SREG
; "", ""
00003b
in
tempi, PINB

00003c ff02
sbrs
tempi, PB2

00003d c012
rjmp
cnt_off

00003effOl
sbrs
tempi, PB1

00003 f c005
rjmp
cnt_on
; 1,

000040
000041
000042
000043
000044

key_out:
;
be4f
SREG, saveF
out
904f
saveF
pop
temph
91 if
pop
tempi
91 Of
pop
9518
reti

cnt on:

000045 2333
tst rent
000046 f7c9
keyout
;
brn
sbrrcnt, 0x80 ; rent
000047 6830
sbn
000048 eO 15
Idi temph, 0x05
TCCR0, temph ;
out
000049 bfl3
00004a 2722
clr counT ;
00004b b927
ADMUX, counT ;
out
00004c 9a36
sbi ADCSR, ADSC ; 1
00004d 98df
cbi PORTA, PA7 ;
00004e 98de
cbi PORTA, PA6 ;
rjmp
keyout
;
00004fcff0

119

cnt_off:
;
000050 2333
tst
rent
000051 f3 71
breq
keyout
;
000052 2733
clr
rent
; rent
000053 2711
clr
temph
000054
out
TCCR0, temph ;
000055 bf!2
out
TCNT0, temph ;
000056 2722
clr
counT ;
000057 98df
cbi PORTA, PA7 ;
000058 98de
cbi PORTA, PA6 ;
waitspi:
000059
cpi XL, low(Mind);
00005 11
breq cnt_end ,
00005b 9478
00005 effe

sei
rjmp

cntend:
00005d dfdO
rcall
00005ecfel
rjmp

;
wait_spi ;

ind_off ;
key_out
;

;
spistc:
0000bd930f
push temp"!
0000be924f
push saveF
OOOObf b64f
in
saveF, SREG
0000c0 30a3
0000c1 f051
0000c2 910d
0000c3 30a2
0000c4 f409
0000c5 6800

cpi XL, low(Mind+3)


breq
load
;
Id
tempi, X+ ;
cpi XL, low(Mind+2)
brne skip
;
sbr tempi, 0x80
;
skip:

b90f
0000c7 b90f

120

out
out

SPDR, tempi
SPDR, tempi

spiout:
;
0008 be4f
out
SREG, saveF
O000c9 904f
pop
saveF
O000ca910f
pop
tempi
O000cb9518
reti
load:
OOOOcc 98c0
OOOOcd 0000
OOOOce 0000
O000cf9ac0
0OOOdOcff7

cbi PORTB, PBO


nop
nop
;
sbi PORTB, PBO ;
rjmp spi_out
;

.ORG 0x0800
cdind:
; ,
000800 063f
000801 4f5b
000802 6d66
000803 077d
000804 6f7f
.dB 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f
;EndOfFile

RESOURCE USE INFORMATION

Notice:
The register and instruction counts are symbol table hit counts,
and hence implicitly used resources are not counted, eg, the
'lpm' instruction without operands implicitly uses rO and z,
none of which are counted.
x,y,z are separate entities in the symbol table and are
counted separately from r26..r31 here.
.dseg memory usage only counts static data declared with .byte
AT90S8535 register use summary:
rO: 1 rl : 0 r2 : 0 r3 : 0 r4 : 16
r 8 : 0 r 9 : 0 rlO: 0 rll: 0 rl2: 0
rl6: 50 rl7: 29 rl8: 7 rl9: 6 r20:
r24: 0 r25: 0 r26: 5 r27: 2 r28:
x : 5 : 0 z : 0
Registers used: 11 out of 35 (31.4%)

r5 : 0
rl3: 0
0 r21:
0 r29:

r6 : 0
rl4: 0
0 r22:
0 r30:

r7 : 0
rl5: 0
0 r23: 0
2 r31: 1

121

AT90S8535 instruction use summary:


adc : 0 add : 4 adiw : 0 and : 0
bclr :: 0 bid ;; 0 brbc : 0 brbs : 0
breq : 12 brge :0
brhc : 0 brhs : 0
brio : 0 brlt : 0
brmi : 0 brne : 4
brtc :: 0 brts : 0
brvc : 0 brvs : 0
clh : 0
clc : 0
cbi : 14 cbr : 0
clr : 20
clt : 0
civ : 0
els : 0
cp : 0
epe : 0 cpi : 18 cpse : 0
icall: 0
ijmp : 0 in : 16
inc : 6
Idi : 32
Ids : 2 1pm : 2 Isl : 0
2
ori : 0
neg : 0 nop : 6 or
push : 20 rcall: 20 ret : 10 reti : 8
ror : 6
sbc : 0 sbci : 0 sbi : 14
sbiw : 0 sbr : 2
sbrc
0 sbrs : 4
sen : 0 ser : 2
ses : 0
sei : 4
sez : 0
std : 0
sleep : 0 st : 8
subi :: 4 swap : 0 tst : 10
wdr : 0
Instructions used: 37 out ofl 00 (37.0%)

andi : 0
brcc : 4
brid : 0
brpl : 0
bset : 0
cli : 0
elz : 0
dec : 0
Id : 21
lsr : 4
out : 48
rjmp : 40
sbic : 4
sec : 0
set : 0
sts : 2

asr : 0
brcs : 8
brie :: 0
brsh : 0
bst : 0
cln : 0
com : 0
eor : 0
dd : 0
mov : 2
pop : 20
rol : 0
sbis : 4
seh : 0
sev : 0
sub : 0

AT90S8535 memory use summary [bytes]:


Segment Begin End Code Data Used Size Use%
[xseg] 0x000000 0x00100a 394 10 400 8192 4.9%
[.dseg] 0x000060 0x000060 0 0 0 512 0.0%
[.eseg] 0x000000 0x000000 0 0 0 5J2 0.0%
Assembly complete, 0 errors, 1 warnings
,
394 , 5% FLASH.

, ( main)
,
.
,
,
,
1 %.
,
(, , ..)
.

(. 9).
10 - 32.
, INT1, 1 2,
122

UART. ,

. ,
:
- .

.

. ,
,
(/), -
.
1 2 .
,
. ,
EEPROM
.
,

, . 7.
UART
. ,

UART.


.
5.3.


AVR Studio 4.X. AVR Studio
Window's- (. 10)
, .
AVR Studio, ,
:
1. (project).
Project ( New Project).
(. 11) - AVR
Assembler, , . "Next"

123

to

. A V R Studio

. 11. "Create new Project"


: Debug Platform - AVR Simulator,
Device - AT90S8535. ,
Project ( File).
.
2. (
.asm), "Workspace"
.
(Create new file)
(Add existing file)
( Project),
Workspace (. 10).
.
,
Window's-.
,

(Set as Entry File).
Project - Build (F7)
.
"Output" (. 10) .
, .
( "Output"),

.
.
125


(Debug
Platform - AVR Simulator). Pro
ject - Build and Run (Ctrl+F7)
. ,
AVR Studio
(
Help).

. 12. I/O
126


"Workspace" I/O (. 12).

.

PC ,
.
"Watch",
.

Hex-
. ,
.

[2].
Hex-
- (
DB15F AVR studio Prog)
. AVR Studio ,
Tools AVR Prog.
AVRprog .

- ( Browse,
, ). Device
(AT90S8515)
- Program Flash
. EEPROM
.
.
5.4. AVR

, ,
,
,

. ,
, ,
, , ,
..
127

.
5,2.
-
.

,
, ..
,
, .

+5 .
-

.
,
.

-.

+5 .
- 20 ,
.
,

.

, (
, ,
..) .

.

,

.
(,
, ..) ""
- ""
,
100
.


128

.
(, )

,
, SPI.
,
, 8-
.
UREF, AREF . N
UBX :

U -
U

BX-

REF

I
2 l

'

UR F 4 ,
UBX 0 4 N $000
$3FF,
. UREF
,

. , REF198E
(Analog Devices) 5
4,096 2
.
4,7 ,


. 50 - 200
, ,
.

.
,
.

. ,

,

.

129



.

, ,
. ,

.

.
- ,
.


1. .., ..
. - .: , 1987.
2. .., ..
: . : - , 2004.

130

SREG

SPH

(5) - 'f ? " *" * * ~ %,

SPL

3D(5D)1

SP7

(5)

INTl

GIMSK
GIFR

5)

INTFi

SP6

s ""v
SP4

\?\^;^**
v

* "

! INTFO
i

TIMSK

39 (59)

OCIE2

TOIC2

1ICIL1

TiFR

38 (58)

OCF2

TOV2

ICF1

MCUCR

35 (55) L c v i l r ^ j

MCUSR

34 (54)

TCCPvO

33 (53)

TCNTO

32 (52)

TCCRIA

2F (4F)

SE

\" '

1
1

: ' ;'SP9

SP8

SP1

SPO

SP2

1111^|^^ ; ;

fc/.4^uV|^|\|

.fife$|&$> < *.; -- "-'*

| OCIE1A ! OC1L1B ' TOIEI

SMI

'*
SP3

& , '*'

H^piMfeapofe

SP5

INTO

~~

3F (5F)

OCF1A

I OCF1B

TO VI

SMO

! ISC 11

ISC 10

" *^%ri

iofE

. .-> ] TOV0
ISCOl

i FSCOO i
1

i TCCR1B

2E (4E)

TCNT1H

2D (4D)

EXTRF : PORT
\1

'

f^Qflfi

0 (8 )
! !
ICNC1

COM] BO

! j COM1B1

ICESI

: \'<*4"\\

i::; Y^rA:

PWM11 j PWM10
CI CI

csiiz

CS11

I ( )

2C (4C)
| TCNT1L
! OCR1AH | 2B (4B) j

1 ( )

j OCR1AL | 2A (4A) 1

I ( )

1 ( )

CS10

'

.
4

OCR1BH

29 (49)

1 ( )

OCR1BL

28 (48)

1 ( )

ICR1H

27 (47)

1 ( )

ICR1L

26 (46)

1 ( )

TCCR2

25 (45)

TCNT2

24 (44)

2 (8 )

OCR2

23 (43)

2 (8 )

ASSR

22(42)

WDTCR

!-& *'\'* 1 PWM2 | 21 J COM20

EEARH

21(41) j ^ : | ^ ^
1F(3F) !vr^?^W': ; ^^V ; "^

EEARL

1()

EEDR

ID (3D)

EECR

EEAR7

EEAR6

DDRA

1()

DDA7 |

DDA6

PINA

19(39)

PINA7 |

P1NA6

] 17(37)

EEAR4

\ <* -* ^,

1()

DDRB

J EEAR5

PORTA

| 18(38)

^] ^^^

CS22

CS21

[ CS20
.

AS2

TCN2UB

WDE
::
";: j EEAR3

WDP2
;

Z'-

OCR2UB | TCR2UB
WDPO
: ]~iEAR8
;V"r> '

WDP1

"

EEAR2 | EEAR1 pEEARO

(EEPROM)

1() ;

PORTB

WDTOE
:

EERIE

EEMWE

PORTA3

PORTA2

DDA4

DDA3

DDA2

PINA4

PINA3

P1NA2

PINA1 | PINAO

PORTB3

PORTB2

PORTB 1 PORTBO

DDB3

DDB2

\:

PORTA7| PORTA6 | PORTA5 ! PORTA4

PORTB7 | PORTB6
DDB7 |

DDB6

DDA5
P1NA5

PORTB5 | PORTB4
DDB5

DDB4

EEWE

EERE

PORTA I j PORTAO
| DDA1

DDB1

DDAO

DDBO

PINB

16(36)

PINB7

6
1 PINB6

PINB5

~~ 2~"

PINB3
PINB2
PINB1
PINB4
PORTC4 |PORTC3 PORTC2 PORTC1

!)

PINB0

j PORTC

15(35)

1 DDRC

14 (34)

DDC7

1 DDC6

DDC5

DDC4

| DDC3

DDC2

DDC1

DDC0

PINC

13 (33)

P1NC7

j PINC6

PINC5

PINC4

PINC2

( PJNC1

PINC0

PORTD

12 (32)

PORTD7

PORTD6

PORTD5

PORTD4

DDRD

11(31)

DDD7

DDD6

DDD5

DDD4

PIND

10 (30)

PIND7

PIND6

PIND5

PIND4

SPDR

OF (2F)

PORTC7 | PORTC6

0E (2E)

SPIF

SPCR

OD (2D)

SP1E

UDR
USR

(2)
OB (2B)

RXC

UCR

0A (2A)

UBRR

09 (29)

ACSR

08 (28)
07 (27)

ADCSR
ADCH

06 (26)
05 (25)
04 (24)

ADCL

PORTC0

PORTD3 PORTD2 PORTD1

PORTD0

DDD3

DDD2

DDD1

DDD0

PIND3

PIND2

PIND1

PIND0 |

SPR1

SPI (8 )

SPSR

ADMUX

PORTC5

WCOL
SPE

DORD

CPOL

MSTR

SPR0

UART (8 )
RXCIE j

UDRE

FE

OR

TXCIE

UDRIE

RXEN

TXEN

\ tfe ^^!^ 4}' \


CHR9

RXB8

8 1

UART (8 )

ACIE

ACI

<:

1 ^!!1^
ADEN |
ADC7

ADSC

ADFR

$^^
ADC6

ADC5

ADIF J

ACIC
ACIS1
ACIS0
ADMUX2 ADMUX1 ADMUX0

* '-<
ADIE

ADPS2

ADPS1
ADC9

ADC4

1 ADC3

ADC2 | ADC1

ADPS0
ADC8
ADC0 j



..
...
..

020565 23.06.1997 . **.*



. ., - 8,3
.-.. - 8
-f"^
j$0 .

'"


17, , 28, , 44


17, , 28, , 1

Оценить