; SMILENGHEADER ; COMMENT This is the Smile NG file header, do not modify! ; VERSION 1.0 ; PROC CALM \prog;Picgt9|Timer par interruptions \b;Beep sur RA4 par interruptions et incrémentation du PortB par boucle d'attente .Proc 16F84 DebVar = 16'20 ; Bits du registre IntCon TOIF = 2 ; Timer interrupt flag TOIE = 5 ; Timer interrupt enable GIE = 7 ; Global interrupt enable ModeIntCon = 2**GIE+2**TOIE ModeOption = 2'00000011 ; Prédiviseur par 16 \var;Registres| .Loc DebVar C1: .Blk.16 1 ; Compteur pour C2: .Blk.16 1 ; boucle d'attente CInt: .Blk.16 1 ; Compteur utilisé par les interruptions CntLow: .Blk.16 1 ; Compteur sur les 4 bits de poids faible MaskLow = 2'00001111 ; Masque pour programme principal MaskHi = 2'11110000 ; Masque pour aff par interruption MotifHi = 2'11000000 ; Motif initial sur le port B SaveW: .Blk.16 1 ; Sauvetage pendant les interruptions SaveF: .Blk.16 1 \var;Ports|RA4 et RB7..0 utilisés en sortie bHP = 4 ; Buzzer sur RA4 DirA = 2'01111 ; RA4 sortie buzzer, RA3..0 entrées DirB = 0 ; Tout en sortie .Loc 0 Jump Deb ; Sauter la zone d'interrupts \prog;Interruptions|Interruption chaque 125 x 16 \mu;s = 2 ms .Loc 4 ; Adresse d'interruption Move W,SaveW ; Ne modifie pas F Swap F,W ; A cause du retour Move W,SaveF TestSkip,BS PortA:#bHP ;- Ces 5 instructions Jump S$ ;- sont équivalentes à Clr PortA:#bHP ;-- Not PortA:#bHP Jump T$ ;- S$: Set PortA:#bHP ;- T$: DecSkip,EQ CInt Jump F$ \b; Chaque 256 x 125 x 16 us = ~0.5s Move PortB,W ; On inverse les bits Xor #MaskHi,W ; concernés de PortB Move W,PortB \m2; F$: Move #256-125,W ; On recharge le timer Move W,TMR0 Clr IntCon:#TOIF ; Flag d'interruption Swap SaveF,W ; Un Move modifierait F!! Move W,F ; artefact du PIC Swap SaveW ; se souvenir du truc Swap SaveW,W ; Un Move modifierait F!! RetI \prog;Initialisations| Deb: Move #DirA,W Move W,TrisA Move #DirB,W Move W,TrisB Clr CInt Clr CntLow ; Compteur 4 bits à zéro Move #MotifHi,W Move W,PortB ; Initialise le motif oscillant Move #ModeOption,W Move W,Option Move #-125,W Move W,TMR0 Move #ModeIntCon,W ; GIE et TOIE activés Move W,IntCon Loop: Inc CntLow ; Tâche du programme principal: Move CntLow,W ; Compter et afficher sur PortB And #MaskLow,W ; On ne garde que ce qui est affichable Move W,CntLow Not PortB,W ; Diodes allumées à zéro And #MaskHi,W ; On efface la partie compteur Or CntLow,W ; On remet la nouvelle valeur Xor #-1,W ; Inverser avant affichage Move W,PortB ; C'est affiché ; Boucle d'attente de 65 ms A$: DecSkip,EQ C1 Jump A$ DecSkip,EQ C2 Jump A$ Jump Loop .End