.include "m8535def.inc"
.def Delay=r17
.def Delay2=r18
RESET:
ser r16
out DDRA,r16
ldi r16,0
out DDRB,r16
ser r16
out DDRC,r16
CICLO: sbis PINB,0x04
rjmp CICLO2
sbis PINB,0x01
inc r19
sbis PINB,0x02
dec r19
out PORTA,r19
;ldi r19,7
ldi r16,1
out PORTC,r16
mov Delay2,r19
DLY21:
dec Delay
brne DLY21
dec Delay2
brne DLY21
ldi r16,3
out PORTC,r16
mov Delay2,r19
DLY22:
dec Delay
brne DLY22
dec Delay2
brne DLY22
ldi r16,2
out PORTC,r16
mov Delay2,r19
DLY23:
dec Delay
brne DLY23
dec Delay2
brne DLY23
ldi r16,6
out PORTC,r16
mov Delay2,r19
DLY24:
dec Delay
brne DLY24
dec Delay2
brne DLY24
ldi r16,4
out PORTC,r16
mov Delay2,r19
DLY25:
dec Delay
brne DLY25
dec Delay2
brne DLY25
ldi r16,12
out PORTC,r16
mov Delay2,r19
DLY26:
dec Delay
brne DLY26
dec Delay2
brne DLY26
ldi r16,8
out PORTC,r16
mov Delay2,r19
DLY27:
dec Delay
brne DLY27
dec Delay2
brne DLY27
ldi r16,9
out PORTC,r16
mov Delay2,r19
DLY28:
dec Delay
brne DLY28
dec Delay2
brne DLY28
rjmp CICLO
CICLO2: sbis PINB,0x03
rjmp CICLO
sbis PINB,0x01
inc r19
sbis PINB,0x02
dec r19
out PORTA,r19
;ldi r19,7
ldi r16,9
out PORTC,r16
mov Delay2,r19
DLY1:
dec Delay
brne DLY1
dec Delay2
brne DLY1
ldi r16,8
out PORTC,r16
mov Delay2,r19
DLY2:
dec Delay
brne DLY2
dec Delay2
brne DLY2
ldi r16,12
out PORTC,r16
mov Delay2,r19
DLY3:
dec Delay
brne DLY3
dec Delay2
brne DLY3
ldi r16,4
out PORTC,r16
mov Delay2,r19
DLY4:
dec Delay
brne DLY4
dec Delay2
brne DLY4
ldi r16,6
out PORTC,r16
mov Delay2,r19
DLY5:
dec Delay
brne DLY5
dec Delay2
brne DLY5
ldi r16,2
out PORTC,r16
mov Delay2,r19
DLY6:
dec Delay
brne DLY6
dec Delay2
brne DLY6
ldi r16,3
out PORTC,r16
mov Delay2,r19
DLY7:
dec Delay
brne DLY7
dec Delay2
brne DLY7
ldi r16,1
out PORTC,r16
mov Delay2,r19
DLY8:
dec Delay
brne DLY8
dec Delay2
brne DLY8
rjmp CICLO2
Es un espacio donde publico notas que creo interesantes desde octubre de 2007.
jueves, 24 de junio de 2010
Control de Motor a pasos con AVR, regulador de velocidad con PIN1 y 2 del puertoB, as{i como cambio de giro con PINES 3 y 4 del mismo puerto
.include "m8535def.inc"
.def Delay=r17
.def Delay2=r18
RESET:
ser r16
out DDRA,r16
ldi r16,0
out DDRB,r16
ser r16
out DDRC,r16
CICLO: sbis PINB,0x04
rjmp CICLO2
sbis PINB,0x01
inc r19
sbis PINB,0x02
dec r19
out PORTA,r19
;ldi r19,7
ldi r16,1
out PORTC,r16
mov Delay2,r19
DLY21:
dec Delay
brne DLY21
dec Delay2
brne DLY21
ldi r16,3
out PORTC,r16
mov Delay2,r19
DLY22:
dec Delay
brne DLY22
dec Delay2
brne DLY22
ldi r16,2
out PORTC,r16
mov Delay2,r19
DLY23:
dec Delay
brne DLY23
dec Delay2
brne DLY23
ldi r16,6
out PORTC,r16
mov Delay2,r19
DLY24:
dec Delay
brne DLY24
dec Delay2
brne DLY24
ldi r16,4
out PORTC,r16
mov Delay2,r19
DLY25:
dec Delay
brne DLY25
dec Delay2
brne DLY25
ldi r16,12
out PORTC,r16
mov Delay2,r19
DLY26:
dec Delay
brne DLY26
dec Delay2
brne DLY26
ldi r16,8
out PORTC,r16
mov Delay2,r19
DLY27:
dec Delay
brne DLY27
dec Delay2
brne DLY27
ldi r16,9
out PORTC,r16
mov Delay2,r19
DLY28:
dec Delay
brne DLY28
dec Delay2
brne DLY28
rjmp CICLO
CICLO2: sbis PINB,0x03
rjmp CICLO
sbis PINB,0x01
inc r19
sbis PINB,0x02
dec r19
out PORTA,r19
;ldi r19,7
ldi r16,9
out PORTC,r16
mov Delay2,r19
DLY1:
dec Delay
brne DLY1
dec Delay2
brne DLY1
ldi r16,8
out PORTC,r16
mov Delay2,r19
DLY2:
dec Delay
brne DLY2
dec Delay2
brne DLY2
ldi r16,12
out PORTC,r16
mov Delay2,r19
DLY3:
dec Delay
brne DLY3
dec Delay2
brne DLY3
ldi r16,4
out PORTC,r16
mov Delay2,r19
DLY4:
dec Delay
brne DLY4
dec Delay2
brne DLY4
ldi r16,6
out PORTC,r16
mov Delay2,r19
DLY5:
dec Delay
brne DLY5
dec Delay2
brne DLY5
ldi r16,2
out PORTC,r16
mov Delay2,r19
DLY6:
dec Delay
brne DLY6
dec Delay2
brne DLY6
ldi r16,3
out PORTC,r16
mov Delay2,r19
DLY7:
dec Delay
brne DLY7
dec Delay2
brne DLY7
ldi r16,1
out PORTC,r16
mov Delay2,r19
DLY8:
dec Delay
brne DLY8
dec Delay2
brne DLY8
rjmp CICLO2
.def Delay=r17
.def Delay2=r18
RESET:
ser r16
out DDRA,r16
ldi r16,0
out DDRB,r16
ser r16
out DDRC,r16
CICLO: sbis PINB,0x04
rjmp CICLO2
sbis PINB,0x01
inc r19
sbis PINB,0x02
dec r19
out PORTA,r19
;ldi r19,7
ldi r16,1
out PORTC,r16
mov Delay2,r19
DLY21:
dec Delay
brne DLY21
dec Delay2
brne DLY21
ldi r16,3
out PORTC,r16
mov Delay2,r19
DLY22:
dec Delay
brne DLY22
dec Delay2
brne DLY22
ldi r16,2
out PORTC,r16
mov Delay2,r19
DLY23:
dec Delay
brne DLY23
dec Delay2
brne DLY23
ldi r16,6
out PORTC,r16
mov Delay2,r19
DLY24:
dec Delay
brne DLY24
dec Delay2
brne DLY24
ldi r16,4
out PORTC,r16
mov Delay2,r19
DLY25:
dec Delay
brne DLY25
dec Delay2
brne DLY25
ldi r16,12
out PORTC,r16
mov Delay2,r19
DLY26:
dec Delay
brne DLY26
dec Delay2
brne DLY26
ldi r16,8
out PORTC,r16
mov Delay2,r19
DLY27:
dec Delay
brne DLY27
dec Delay2
brne DLY27
ldi r16,9
out PORTC,r16
mov Delay2,r19
DLY28:
dec Delay
brne DLY28
dec Delay2
brne DLY28
rjmp CICLO
CICLO2: sbis PINB,0x03
rjmp CICLO
sbis PINB,0x01
inc r19
sbis PINB,0x02
dec r19
out PORTA,r19
;ldi r19,7
ldi r16,9
out PORTC,r16
mov Delay2,r19
DLY1:
dec Delay
brne DLY1
dec Delay2
brne DLY1
ldi r16,8
out PORTC,r16
mov Delay2,r19
DLY2:
dec Delay
brne DLY2
dec Delay2
brne DLY2
ldi r16,12
out PORTC,r16
mov Delay2,r19
DLY3:
dec Delay
brne DLY3
dec Delay2
brne DLY3
ldi r16,4
out PORTC,r16
mov Delay2,r19
DLY4:
dec Delay
brne DLY4
dec Delay2
brne DLY4
ldi r16,6
out PORTC,r16
mov Delay2,r19
DLY5:
dec Delay
brne DLY5
dec Delay2
brne DLY5
ldi r16,2
out PORTC,r16
mov Delay2,r19
DLY6:
dec Delay
brne DLY6
dec Delay2
brne DLY6
ldi r16,3
out PORTC,r16
mov Delay2,r19
DLY7:
dec Delay
brne DLY7
dec Delay2
brne DLY7
ldi r16,1
out PORTC,r16
mov Delay2,r19
DLY8:
dec Delay
brne DLY8
dec Delay2
brne DLY8
rjmp CICLO2
Suscribirse a:
Entradas (Atom)