Problema con AVR at90usb1286

La cuestion es que tengo mi programa listo, pareciera estar todo bien, pero cuando lo simulo en proteus no corre bien. Ya lo he puesto en la realidad y hace lo mismo que en el proteus...

Les dejo mi programa y la simulacion en proteus.

.list
.include "usb1286def.inc"
.nolist

.def temp = r21

.equ ocl = 0x0100
.equ och = 0x0101

.org $0000
rjmp reset

reset:
ldi temp, high(RAMEND)
sts SPH, temp
ldi temp, low(RAMEND)
sts SPL, temp

ldi temp, 0x07
out DDRD, temp

ldi temp, 0xFF
out DDRC, temp

ldi temp, 0x20
out DDRB, temp

cbi PinD,1
sbi PinD,2

ldi temp, 0x00
out PinC, temp

ldi temp, 0x00;
sts och, temp
sts ocl, temp

rcall confReloj
revisar:
sbic PinD,3
rcall mas

sbic PinD,4
rcall menos

ldi r17, byte3(70000)
ldi r18, high(70000)
ldi r19, low(70000)
rcall delay
rjmp revisar



confReloj:
ldi temp, high(15625)
sts ICR1H, temp

ldi temp, low(15625)
sts ICR1L, temp

ldi temp,0b10000010
sts TCCR1A, temp

ldi temp,0b00011011
sts TCCR1B,temp

ldi temp,0b00000000
sts TCCR1C,temp

ldi temp, high(0)
sts OCR1AH, temp

ldi temp, low(0)
sts OCR1AL, temp

ret

mas:
lds r16, ocl
lds r17, och
ldi temp, high(15624)
cpi r16, low(15624)
cpc r17, temp
breq finma
ldi temp, low(1953)
add r16, temp
ldi temp, high(1953)
adc r17, temp
sts ocl, r16
sts och, r17
sts OCR1AL, r16
sts OCR1AH, r17
in temp, PinC
inc temp
out PortC, temp
finma: ret

menos:
lds r16, ocl
lds r17, och
ldi temp, high(0)
cpi r16, low(0)
cpc r17, temp
breq finme
subi r16, low(1953)
sbci r17, high(1953)
sts ocl, r16
sts och, r17
sts OCR1AL, r16
sts OCR1AH, r17
in temp, PinC
dec temp
out PortC, temp
finme: ret

delay:
subi r19, 1
sbci r18, 0
sbci r17, 0
brcc pc-3
ret


Para programar use el avr studio. Lo debug ahi y me parecio que corria bien. no se si tengo algo mal configurado en el avr.. o si realmente soy malo para esto..

Adjunto: la simulacion en proteus
 

Adjuntos

  • Simulacion.rar
    30 KB · Visitas: 1
Atrás
Arriba