J'essaie de mettre un pied dans les 18F. Comme aide pour les configs je me sers du code qu'a posté Temps-X dans le sujet 'Soft Commande CNC'.
Par contre je manque cruellement d'infos sur les interrupt et j'ai le nez dans le datasheet mais pas simple avec mon anglais primaire
Première question:
Temps-X, un truc me chiffonne, la première zone des variables commence à H'0' et le départ après reset également. Normal ? il me semble qu'il y a conflit, la première ligne 'goto début' va écraser les premières variables loop1, loop2, etc. ?
Autre question:
Pour faire simple au début je compte ne pas mettre de priorités aux interruptions, donc registre RCON --> IPEN=0 si j'ai bien pigé. Mais du coup ou commencent les interrupt ? à H'8' ou bien H'18' ?
Code : Tout sélectionner
;**********************************************************************************************
Errorlevel-302 ; Supprime le message "Ensure that bank bits are correct"
list p=18f4525 ; processeur utilisé
#include <p18f4525.inc> ; Définitions des constantes
;**********************************************************************************************
CONFIG OSC = XT ; Oscillateur ext 4MHz
CONFIG IESO = OFF ; Oscillateur secondaire refusé (ON/OFF)
CONFIG PWRT = ON ; Délai au démarrage (ON/OFF)
CONFIG BOREN = OFF ; Reset si chute de tension (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 = OFF ; 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)
;*************************************** assignations *****************************************
; #DEFINE
;****************************** déclaration des variables *************************************
CBLOCK H'0'
loop1
loop2
loop3
loop4
loop5
ENDC
CBLOCK H'80'
wreg_temps
status_temps
bsr_temps
ENDC
;**************************** adresse de depart après reset ******************************
ORG H'0'
goto debut
;*************************** interruption haute priorité *********************************
ORG H'8'
retfie
;*************************** interruption basse priorité *********************************
ORG H'18'
movff STATUS,status_temps ; sauve STATUS register
movff WREG,wreg_temps ; sauve registe de travaille
movff BSR,bsr_temps ; sauve le BSR registe
movff bsr_temps,BSR ; restore BSR
movff wreg_temps,WREG ; restore registe de travail
movff status_temps,STATUS ; restore STATUS
retfie
;**********************************************************************************************
debut
movlw B'01110011'
movwf OSCCON ; oscillateur à 8 Mhz
movlw B'00001111'
movwf ADCON1 ; mode analogique
clrf TRISA
clignote
call _1s
bsf PORTA,0
call _1s
bcf PORTA,0
bra clignote
;************************** tempo de 1 seconde ****************************************
_1s
movlw D'93'
movwf loop1
movlw D'38'
movwf loop2
movlw D'11'
movwf loop3
decfsz loop1
bra $-D'2'
decfsz loop2,F
bra $-D'6'
decfsz loop3,F
bra $-D'10'
return
end
