;====================================================================
; [Link] file generated by New Project wizard
; Created: Tue Dec 10 2024
; Processor: PIC16F877A
; Compiler: MPASM (Proteus)
; === Configuration des bits de configuration ===
; === Configuration des bits de configuration ===
;Exercice 1 : Clignotement de LED avec Timer0
;Objectif : Faire clignoter une LED connectée à RB0 toutes les 500 ms à l'aide du Timer0
LIST P=16F877A
#include <[Link]>
__CONFIG _XT_OSC & _WDT_OFF & _PWRTE_ON & _CP_OFF
; === Début du programme ===
ORG 0x00 ; Adresse de démarrage
GOTO Main ; Aller au programme principal
; === Vecteur d'interruption ===
ORG 0x04
ISR:
BTFSS INTCON, 2 ; Vérifier si l'interruption TMR0 est active (T0IF)
RETFIE ; Si non, retour de l'interruption
BCF INTCON, 2 ; Effacer le flag T0IF
MOVLW 0x01 ; Charger un masque pour RB0
XORWF PORTB, F ; Basculer RB0
RETFIE ; Retour de l'interruption
; === Programme principal ===
Main:
; Configuration des ports
BSF STATUS, 5 ; Passer en BANK1
CLRF TRISB ; Configurer PORTB en sortie (RB0)
BCF STATUS, 5 ; Revenir à BANK0
CLRF PORTB ; Initialiser PORTB à 0 (LED éteinte)
; Configuration du Timer0
BSF STATUS, 5 ; Passer en BANK1
MOVLW 0x07 ; Prescaler 1:256 (OPTION_REG = 0b00000111)
MOVWF OPTION_REG
BCF STATUS, 5 ; Revenir à BANK0
; Activer les interruptions
CLRF INTCON ; Désactiver toutes les interruptions
BSF INTCON, 5 ; Activer l'interruption TMR0 (T0IE)
BSF INTCON, 7 ; Activer les interruptions globales (GIE)
; Boucle principale
Loop:
GOTO Loop ; Boucle infinie
END