.


:




:

































 

 

 

 


1 . : 43200; clk/256; 1


.include "m128def.inc"

.equ CS_clk256 = 0x04; .

.equ cycles = 1;

.equ presetup = 0; ..

.equ comp_value = 43200

.def temp = R16; .

.def key_code = R17; .

.def ovf_count = r18;

jmp RESET

.org $0018

jmp T1_COMPA; . . 1

.org $0046

RESET:

;

ldi temp,high(RAMEND)

out SPH,temp

ldi temp, low(RAMEND)

out SPL,temp

; ( 0-2)

ldi temp,0xE0

out PORTB, temp; 11100000

ldi temp, 0x00

out DDRB,temp;

;

ldi temp,0xFF

out PORTD,temp;

out DDRD,temp

;

ldi ovf_count,0

ldi key_code,0

; 1

ldi temp,high(presetup)

out TCNT1H,temp

ldi temp,low(presetup)

out TCNT1L,temp

;

ldi temp,high(comp_value)

out OCR1AH,temp

ldi temp,low(comp_value)

out OCR1AL,temp

ldi temp, (1<<OCIE1A)

out TIMSK,temp; . .

Sei

ldi temp, (1<<CS12); clk /256

out TCCR1B,temp

Main:

in temp,PINB

andi temp,0xE0

sbrs temp,7

ldi key_code,4

sbrs temp,6

ldi key_code,2

sbrs temp,5

ldi key_code,1

rjmp Main

T1_COMPA:

inc ovf_count

sbrc ovf_count,5

rjmp bit_is_set

sbi PORTD,6

rjmp go_on

bit_is_set:

cbi PORTD,6

go_on:

cpi ovf_count,cycles

brne exit_int

com key_code

out PORTD,key_code

clr key_code

clr ovf_count

exit_int:

reti


 

 

:

 

:

2) :


.include "m128def.inc"

.equ cycles = 42;chislo perepolneniya do 2 sek.

.equ presetup = 0;nachalo yst. t\ch=1

.def temp = R16

.def key_code = R17;kod nawatoyi clavishi

.def ovf_count = R18;chetchit perepolnen

; segment vectorov prerivaniya

jmp RESET

.org $001C

jmp T1_OVF

.org $0046; segment osnovnogo koda

RESET:

; initcializ steka

ldi temp, high(RAMEND)

out SPH, temp

ldi temp, low(RAMEND)

out SPL, temp

;iniz porta B

ldi temp, 0xE0

out PORTB, temp

ldi temp, 0x00

out DDRB, temp

;inizializatciya porta D(diodi)

ldi temp, 0xFF

out PORTD, temp

out DDRD, temp

;iniz global. peremennix

ldi ovf_count, 0

ldi key_code, 0

;iniz t\ch 1

ldi temp, high (presetup)

out TCNT1H, temp

ldi temp, low (presetup)

out TCNT1L, temp

;clk/8: CS1(2:0) = {010}

ldi temp, (1<<TOIE1)

out TIMSK, temp

sei

ldi temp, (1<<CS11)

out TCCR1B, temp

MAIN:

;chitivanie i fikcaciya koda nawatoi klavishi

in temp, PINB

andi temp, 0xE0

sbrs temp, 7

ldi key_code, 4

sbrs temp, 6

ldi key_code, 2

sbrs temp, 5

ldi key_code, 1

rjmp MAIN

;obrabotka preriv po perepopl T1

T1_OVF:

; indicator raboti t/ch 1

inc ovf_count

sbrc ovf_count, 5

rjmp go_on

bit_is_set:

cbi PORTD, 7

go_on:

cpi ovf_count, cycles

brne exit_int

com key_code

out PORTD,key_code

clr key_code

clr ovf_count

exit_int:

reti



3:

 


.include "m128def.inc"

.equ CS_clk256 = 0x04

.equ cycles = 1

.equ presetup = 43936

.equ comp_value = 43200

.def temp = R16

.def key_code = R17

.def ovf_count = r18

jmp RESET

.org $001c

jmp T1_OVF

.org $0046

RESET:

ldi temp,high(RAMEND)

out SPH,temp

ldi temp, low(RAMEND)

out SPL,temp

ldi temp,0xE0

out PORTB, temp

ldi temp, 0x00

out DDRB,temp

ldi temp,0xFF

out PORTD,temp

out DDRD,temp

ldi ovf_count,0

ldi key_code,0

ldi temp,high(presetup)

out TCNT1H,temp

ldi temp,low(presetup)

out TCNT1L,temp

;ldi temp,high(comp_value)

;out OCR1AH,temp

;ldi temp,low(comp_value)

;out OCR1AL,temp

ldi temp, (1<<TOIE1)

out TIMSK,temp

sei

ldi temp, (1<<CS12|1<<CS10)

out TCCR1B,temp

Main:

in temp,PINB

andi temp,0xE0

sbrs temp,7

ldi key_code,4

sbrs temp,6

ldi key_code,2

sbrs temp,5

ldi key_code,1

rjmp Main

T1_OVF:

inc ovf_count

sbrc ovf_count,5

rjmp bit_is_set

sbi PORTD,6

rjmp go_on

bit_is_set:

cbi PORTD,6

go_on:

cpi ovf_count,cycles

brne exit_int

com key_code

out PORTD,key_code

clr key_code

clr ovf_count

exit_int:

ldi R19,high(presetup)

out TCNT1H,R19

ldi R19,low(presetup)

out TCNT1L,R19

reti


 

 

: / 1 , .

 

 



<== | ==>
̳ : , , | (1867)
:


: 2017-02-28; !; : 247 |


:

:

- , - .
==> ...

1435 - | 1362 -


© 2015-2024 lektsii.org - -

: 0.021 .