;----------------------------------------------------- ; TESTMOVING.ASM - By Claudio Fin 2002 ;----------------------------------------------------- ;----------------------------------------------------- ; Utilizzo porte ;----------------------------------------------------- ; RB5 (out) running led (0=acceso 1=spento) ; RB6 (out) direzione motore sinistro (1=avanti 0=indietro) ; RB7 (out) direzione motore destro (1=avanti 0=indietro) ; ; RC1 (out) CCP2 PWM motore destro (duty 100%=motore fermo) ; RC2 (out) CCP1 PWM motore sinistro (duty 100%=motore fermo) ;----------------------------------------------------- PROCESSOR 16F877 RADIX DEC INCLUDE "P16F877.INC" INCLUDE "pwrasm.inc" __CONFIG 11111100111010B ORG 20H cont RES 2 cont2 RES 1 ORG 0 Ldf PORTB,11100000B Ldf PORTC,00000110B Bank1 clrf TRISB clrf TRISC Bank0 Ldf PORTB,11100000B Ldf PORTC,00000110B Bank1 Ldf PR2,127 Bank0 Ldf CCPR1L,128 Ldf CCPR2L,128 Ldf T2CON,00000110B movlw 00111100B iorwf CCP1CON,f iorwf CCP2CON,f main call avall call del1 call stopall call del1 call avdx call indsx call del1 call indall call del1 call stopsx call del1 call indsx call stopdx call del1 call avall call del1 call stopsx call del1 call stopall call del1 goto main del1 Ldf cont2,15 del2 Delay16 cont,255,255 Djnz cont2,del2 return ;----------------------------------------------------- ; Subroutines controllo motori ;----------------------------------------------------- stopall Ldf CCPR1L,128 Ldf CCPR2L,128 return avall bsf PORTB,6 bsf PORTB,7 Ldf CCPR1L,37 Ldf CCPR2L,25 return indall bcf PORTB,6 bcf PORTB,7 Ldf CCPR1L,31 Ldf CCPR2L,37 return stopsx Ldf CCPR1L,128 return stopdx Ldf CCPR2L,128 return avsx bsf PORTB,6 Ldf CCPR1L,37 return avdx bsf PORTB,7 Ldf CCPR2L,25 return indsx bcf PORTB,6 Ldf CCPR1L,31 return inddx bcf PORTB,7 Ldf CCPR2L,37 return ;----------------------------------------------------- END