Code : Tout sélectionner
;************************************************************************************************
; F6FCO
; Hello World
; 28 oct 2023
;
;
Errorlevel-302 ; Supprime le message "Ensure that bank bits are correct"
list p=18f2620 ; processeur utilisé
#include <p18f2620.inc> ; Définitions des constantes PIC
CONFIG OSC = INTIO67 ; Oscillateur interne 8MHz
CONFIG IESO = OFF ; Délai au démarrage (ON/OFF)
CONFIG BOREN = OFF ; Reset si chute de tension (ON/OFF)
CONFIG PWRT = ON ; Délai au démarrage (ON/OFF)
CONFIG BORV = 0 ; Tension de reset en 1/10ème Volts
CONFIG WDT = OFF ; Mise hors service du watchdog (ON/OFF)
CONFIG PBADEN = OFF ; PORTB<4:0> les broches sont configurées comme E/S numériques lors de la réinitialisation
CONFIG LPT1OSC = OFF ; Timer1 configuré pour un fonctionnement plus puissant
CONFIG MCLRE = ON ; Mclr configuré comme entrée
CONFIG STVREN = ON ; Reset sur débordement de pile (ON/OFF)
CONFIG LVP = OFF ; Programmation basse tension autorisée (ON/OFF)
CONFIG XINST = OFF ; L'extension du jeu d'instructions et le mode d'adressage indexé sont désactivés(mode hérité)
CONFIG DEBUG = OFF ; Debugger hors service
CONFIG CP0 = OFF ; Code protection sur block 0 (ON/OFF)
CONFIG CP1 = OFF ; Code protection sur block 1 (ON/OFF)
CONFIG CP2 = OFF ; Code protection sur block 2 (ON/OFF)
CONFIG CPB = OFF ; Code protection sur bootblock (ON/OFF)
CONFIG CPD = OFF ; Code protection sur eeprom (ON/OFF)
CONFIG WRT0 = OFF ; Protection écriture block 0 (ON/OFF)
CONFIG WRT1 = OFF ; Protection écriture block 1 (ON/OFF)
CONFIG WRT2 = OFF ; Protection écriture block 2 (ON/OFF)
CONFIG WRTB = OFF ; Protection écriture bootblock (ON/OFF)
CONFIG WRTC = OFF ; Protection écriture configurations (ON/OFF)
CONFIG WRTD = OFF ; Protection écriture zone eeprom (ON/OFF)
CONFIG EBTR0 = OFF ; Protection lecture de table block 0 (ON/OFF)
CONFIG EBTR1 = OFF ; Protection lecture de table block 1 (ON/OFF)
CONFIG EBTR2 = OFF ; Protection lecture de table block 2 (ON/OFF)
CONFIG EBTRB = OFF ; Protection lecture de table bootblock (ON/OFF)
MasqueIntcon EQU H'00A0' ; réglage interruptions Timer0
CBLOCK H'0'
;--------------- variables
Reg_1 :1 ; tempo
Reg_2 :1 ; tempo
Reg_3 :1 ; tempo
conchita :2 ; variable bonne à tout faire
LcdLigne :1 ; LCD
LcdColonne :1 ; LCD
w_temp :1 ; Sauvegarde du registre W
status_temp : 1 ; Sauvegarde du registre STATUS
cmpt : 1
ENDC
org 0x000 ; Adresse de départ après reset
bra init ; Adresse 0: initialiser
; ------------------------ Routines Interruptions
;sauvegarder registres
org 0x008 ; adresse d'interruption
movwf w_temp ; sauver registre W
swapf STATUS,w ; swap status avec résultat dans w
movwf status_temp ; sauver status swappé
; Interrupt TIMER0
btfsc INTCON,TMR0IE ; interrupt timer autorisée ?
btfss INTCON,TMR0IF ; si oui, tester si interrupt timer en cours
bra restorereg
call inttimer ; vers routine interrupt timer
bcf INTCON,TMR0IF ; effacer flag interrupt timer
;restaurer registres
restorereg
swapf status_temp,w ; swap ancien status, résultat dans w
movwf STATUS ; restaurer status
swapf w_temp,f ; Inversion L et H de l'ancien W
; sans modifier Z
swapf w_temp,w ; Réinversion de L et H dans W
; W restauré sans modifier status
retfie ; return from interrupt
; Routine d'interruption TIMER 0
inttimer
decfsz cmpt,f ; décrémenter compteur de passages
return ; pas 0, on ne fait rien
movlw b'00000010' ; sélectionner bit à inverser
xorwf PORTB , f ; inverser LED
movlw d'7' ; on recommence à décompter
movwf cmpt
return ; fin d'interruption timer
; ------------------------ Init
init
clrf PORTA
clrf PORTB
clrf EEADR ; diminue la consommation
movlw h'C7' ; Timer0 interne avec prescaler 256
movwf T0CON
movlw 0Fh
movwf ADCON1 ; mode digital
movlw b'00000000'
movwf TRISA
movwf TRISB
movlw MasqueIntcon ; masque interruption
movwf INTCON ; charger interrupt control
movlw d'7'
movwf cmpt
; -----------------------------------
main
nop
bra main
END
