Documentos de Académico
Documentos de Profesional
Documentos de Cultura
.include "m164pdef.inc"
.def tempo=r16
.cseg
.org 0x00
ldi tempo,0b00110000
out ddrd,tempo
ldi tempo,high(15624)
sts ocr1ah,tempo
ldi tempo,low(15624)
sts ocr1al,tempo
ldi tempo,0b01010000
sts tccr1a,tempo
ldi tempo,0b00001100
sts tccr1b,tempo
lazo:
rjmp lazo
SECUENCIA TIMER1
.include "m164pdef.inc"
.def tempo=r16
.cseg
.org 0x00
rjmp inicio
.org 0x1a
rjmp secuencia
inicio:
ldi tempo,255
out ddra,tempo
clr tempo
out porta,tempo
ldi tempo,low(ramend)
out spl,tempo
ldi tempo,high(ramend)
out sph,tempo
ldi tempo,high(31249)
sts ocr1ah,tempo
ldi tempo,low(31249)
sts ocr1al,tempo
ldi tempo,0b00000000
sts tccr1a,tempo
ldi tempo,0b00001100
sts tccr1b,tempo
ldi tempo,0b00000010
sts timsk1,tempo
sei
ldi r17,0b00000001
ldi r18,0
lazo:
rjmp lazo
secuencia:
out porta,r17
sbrc r17,7
ldi r18,0
sbrc r17,0
ldi r18,255
tst r18
sbrc r18,0
rjmp cambiar
lsr r17
rjmp salir
cambiar:
lsl r17
salir:
reti
TIMER2 ASINCRONICO
.include"m164pdef.inc"
.def tempo=r16
.org 0x00
ldi tempo,0b10000000
out ddrd,tempo
com tempo
out portd,tempo
ldi tempo,15
sts ocr2a,tempo
ldi tempo,0b01000010
sts tccr2a,tempo
ldi tempo,0b00000111
sts tccr2b,tempo
ldi tempo,0b00100000
sts assr,tempo
lazo:
rjmp lazo
TIMER0 PWM
.include "m164pdef.inc"
.def tempo=r16
.org 0x00
rjmp inicio
.org 0x02
rjmp subir
.org 0x04
rjmp bajar
inicio:
ldi tempo,0b0011000
out ddrb,tempo
com tempo
out portb,tempo
clr tempo
out ddrd,tempo
com tempo
out portd,tempo
ldi tempo,0b00001010
sts eicra,tempo
ldi tempo,0b00000011
out eimsk,tempo
ldi tempo,0b10100001
out tccr0a,tempo
ldi tempo,62
out ocr0a,tempo
ldi tempo,5
out ocr0b,tempo
ldi tempo,0b00001011
out tccr0b,tempo
sei
ldi r17,10
ldi tempo,0b00000001
sts didr0,tempo
ldi tempo,0b01100000
sts admux,tempo
lazo:
ldi tempo,0b11000010
sts ADCSRA,tempo
ESPERA:
lds r27,adcsra
sbrc r27,6
rjmp espera
lds r27,adch
cpi r27,240
brcc lazo
cpi r27,5
brcs lazo
out ocr0a,r27
rjmp lazo
subir:
in r18,ocr0a
subi r18,11
in tempo,ocr0b
cp tempo,r18
brcc salir
add tempo,r17
out ocr0b,tempo
salir:
reti
bajar:
in tempo,ocr0b
cpi tempo,6
brcs salir1
sub tempo,r17
out ocr0b,tempo
salir1:
reti