;*********************************************************** ; projet : chenillard ; auteur : PSi ; création : 01/07/2007 ; version : 1.0 ; affichage bandeau lumineux pour sept lettres ;********************************************************** LIST p=PIC16F628A ; Définition de processeur #include ; Définitions des constantes errorlevel -302 __CONFIG _CP_OFF & _DATA_CP_ON & _LVP_OFF & _BOREN_OFF & _MCLRE_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT ; __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_OFF & _HS_OSC ;********************************************************** ; VARIABLES ;********************************************************** CBLOCK 0x040 ; début de la zone variables VA_CPT1 : 1 ; variables des compteurs de délai VA_CPT256 : 1 VA_CPT10 : 1 ENDC ;********************************************************************* ; MACRO * ;********************************************************************* BANK0 macro bcf STATUS , RP0 ; passer banque0 endm BANK1 macro bsf STATUS , RP0 ; passer banque1 endm ;********************************************************** ; DEFINE ;********************************************************** #define IO_LETTRE1 PORTB,0 #define IO_LETTRE2 PORTB,1 #define IO_LETTRE3 PORTB,2 #define IO_LETTRE4 PORTB,3 #define IO_LETTRE5 PORTB,4 #define IO_LETTRE6 PORTB,5 #define IO_LETTRE7 PORTB,6 #define IO_LETTRE8 PORTB,7 ;********************************************************************** ; DEMARRAGE SUR RESET * ;********************************************************************** org 0x000 ; Adresse de départ après reset goto ET_init ; Adresse 0: initialiser ;********************************************************************** ; ROUTINE INTERRUPTION * ;********************************************************************** ; sauvegarder registres ;-------------------------------------- org 0x004 ; adresse d'interruption ; aucune interruption n'est utilisée retfie ; return from interrupt ; ;********************************************************************* ; PROGRAMME PRINCIPAL * ;********************************************************************* ET_init ; initialisation registres * ;********************************************************************** ; registre option OPTION_REG dans BANK1 BANK1 clrf OPTION_REG ; résistance detappel sur PORTB clrf PIE1 clrf PCON bsf PCON, OSCF ; oscillateur interne à 4MHz movlw h'FF' ; par défaut, toutes les E/S movwf TRISA ; sont en "entrée" movwf TRISB ; c'sest à dire à haute impédance clrf VRCON ; référence de courant désactivé BANK0 clrf INTCON ; toutes les interruption désactivées clrf PORTA ; toutes les E/S clrf PORTB ; à 0 au départ clrf T1CON ; Timer1 désactivé clrf T2CON ; Timer2 désactivé clrf CCP1CON ; capture/compare/PWM déactivé clrf RCSTA ; USART désactivé clrf CMCON ; comparateurs désactivés ;********************************************************** ; PARAMETRES ;********************************************************** BANK1 clrf TRISB ; PORTB en sortie BANK0 ;********************************************************** ; BOUCLE PRINCIPALE ;********************************************************** ET_Boucle_Principale call SP_CHENIL_D call SP_CHENIL_G call SP_CHENIL_IMPAIR call SP_CHENIL_TRIPLE_G call SP_CHENIL_TRIPLE_D call SP_ECRITURE call SP_CLIGNOT call SP_EFFACEMENT goto ET_Boucle_Principale ;************************************************************************ ; sous-programme ECRITURE * ; allumage de toutes les lettres en partant de la gauche * ;************************************************************************ SP_ECRITURE clrf PORTB call SP_delai bsf IO_LETTRE1 call SP_delai bsf IO_LETTRE2 call SP_delai bsf IO_LETTRE3 call SP_delai bsf IO_LETTRE4 call SP_delai bsf IO_LETTRE5 call SP_delai bsf IO_LETTRE6 call SP_delai bsf IO_LETTRE7 call SP_delai bsf IO_LETTRE8 call SP_delai return ;************************************************************************ ; sous-programme CHENILLARD * ; chenillard de gauche à droite * ;************************************************************************ SP_CHENIL_D clrf PORTB bsf IO_LETTRE1 call SP_delai bsf IO_LETTRE2 bcf IO_LETTRE1 call SP_delai bsf IO_LETTRE3 bcf IO_LETTRE2 call SP_delai bsf IO_LETTRE4 bcf IO_LETTRE3 call SP_delai bsf IO_LETTRE5 bcf IO_LETTRE4 call SP_delai bsf IO_LETTRE6 bcf IO_LETTRE5 call SP_delai bsf IO_LETTRE7 bcf IO_LETTRE6 call SP_delai bsf IO_LETTRE8 bcf IO_LETTRE7 call SP_delai return SP_EFFACEMENT ;************************************************************************ ; sous-programme EFFACEMENT * ; extinction de toutes les lettres en partant de la gauche * ;************************************************************************ call SP_delai bcf IO_LETTRE1 call SP_delai bcf IO_LETTRE2 call SP_delai bcf IO_LETTRE3 call SP_delai bcf IO_LETTRE4 call SP_delai bcf IO_LETTRE5 call SP_delai bcf IO_LETTRE6 call SP_delai bcf IO_LETTRE7 call SP_delai bcf IO_LETTRE8 call SP_delai return SP_CLIGNOT ;************************************************************************ ; sous-programme CLIGNOTEMENT * ; clignatement de toutes les lettres (4 fois) * ;************************************************************************ call SP_delai movlw b'11111111' movwf PORTB call SP_delai clrf PORTB call SP_delai movlw b'11111111' movwf PORTB call SP_delai clrf PORTB call SP_delai movlw b'11111111' movwf PORTB call SP_delai clrf PORTB call SP_delai movlw b'11111111' movwf PORTB call SP_delai clrf PORTB call SP_delai movlw b'11111111' movwf PORTB call SP_delai clrf PORTB return ;************************************************************************ ; sous-programme délai * ; délai donné par niveau1 X niveau2 X 256 * ;************************************************************************ SP_delai movlw d'15' ; chargement compteur niveau1 movwf VA_CPT1 ET_delai1 decfsz VA_CPT1,f ; décrément niveau1 goto ET_delai2 ; exécute niveau2 return ; fin délai si niveau1 à 0 ET_delai2 movlw d'50' ; chargement compteur niveau2 movwf VA_CPT10 ET_delai3 decfsz VA_CPT10,f ; décrément niveau2 goto ET_delai4 ; exécution niveau3 goto ET_delai1 ; retour niveau1 si 0 (fin niveau2) ET_delai4 decfsz VA_CPT256,f ; décrément niveau3 goto ET_delai4 ; boucle exécutée 256 fois goto ET_delai3 ; retour niveau2 si 0 (fin niveau3) ;************************************************************************ ; sous-programme CHENILLARD * ; chenillard impair de gauche à droite * ;************************************************************************ SP_CHENIL_IMPAIR clrf PORTB call SP_delai bsf IO_LETTRE1 call SP_delai bsf IO_LETTRE3 bcf IO_LETTRE1 call SP_delai bsf IO_LETTRE5 bcf IO_LETTRE3 call SP_delai bsf IO_LETTRE7 bcf IO_LETTRE5 call SP_delai bsf IO_LETTRE5 bcf IO_LETTRE7 call SP_delai bsf IO_LETTRE3 bcf IO_LETTRE5 call SP_delai bsf IO_LETTRE1 bcf IO_LETTRE3 call SP_delai return ;************************************************************************ ; sous-programme CHENILLARD * ; chenillard pair de gauche à droite * ;************************************************************************ SP_CHENIL_PAIR bsf IO_LETTRE2 bcf IO_LETTRE1 call SP_delai bsf IO_LETTRE4 bcf IO_LETTRE2 call SP_delai bsf IO_LETTRE6 bcf IO_LETTRE4 call SP_delai bsf IO_LETTRE8 bcf IO_LETTRE6 call SP_delai bsf IO_LETTRE6 bcf IO_LETTRE8 call SP_delai bsf IO_LETTRE4 bcf IO_LETTRE6 call SP_delai bsf IO_LETTRE2 bcf IO_LETTRE4 call SP_delai return ;************************************************************************ ; sous-programme CHENILLARD * ; chenillard 3 par 3 de gauche à droite * ;************************************************************************ SP_CHENIL_TRIPLE_G clrf PORTB bsf IO_LETTRE1 call SP_delai bsf IO_LETTRE2 call SP_delai bsf IO_LETTRE3 call SP_delai bsf IO_LETTRE4 bcf IO_LETTRE1 call SP_delai bsf IO_LETTRE5 bcf IO_LETTRE2 call SP_delai bsf IO_LETTRE6 bcf IO_LETTRE3 call SP_delai bsf IO_LETTRE7 bcf IO_LETTRE4 call SP_delai bsf IO_LETTRE8 bcf IO_LETTRE5 bcf IO_LETTRE6 bcf IO_LETTRE7 call SP_delai return ;************************************************************************ ; sous-programme CHENILLARD * ; chenillard 3 par 3 de droite à gauche * ;************************************************************************ SP_CHENIL_TRIPLE_D clrf PORTB bsf IO_LETTRE8 call SP_delai bsf IO_LETTRE7 call SP_delai bsf IO_LETTRE6 call SP_delai bsf IO_LETTRE5 bcf IO_LETTRE8 call SP_delai bsf IO_LETTRE4 bcf IO_LETTRE7 call SP_delai bsf IO_LETTRE3 bcf IO_LETTRE6 call SP_delai bsf IO_LETTRE2 bcf IO_LETTRE5 call SP_delai bsf IO_LETTRE1 bcf IO_LETTRE4 call SP_delai bcf IO_LETTRE3 call SP_delai bcf IO_LETTRE2 call SP_delai bcf IO_LETTRE1 call SP_delai return ;****************************************************************************** ; sous programme chenilard de droite à gauche ;******************************************************************************* SP_CHENIL_G clrf PORTB call SP_delai bsf IO_LETTRE8 call SP_delai bsf IO_LETTRE7 bcf IO_LETTRE8 call SP_delai bsf IO_LETTRE6 bcf IO_LETTRE7 call SP_delai bsf IO_LETTRE5 bcf IO_LETTRE6 call SP_delai bsf IO_LETTRE4 bcf IO_LETTRE5 call SP_delai bsf IO_LETTRE3 bcf IO_LETTRE4 call SP_delai bsf IO_LETTRE2 bcf IO_LETTRE3 call SP_delai bsf IO_LETTRE1 bcf IO_LETTRE2 call SP_delai return END