28.02.2015 Views

TP n° 1 Prise en main de MPLAB 6 - LIAS

TP n° 1 Prise en main de MPLAB 6 - LIAS

TP n° 1 Prise en main de MPLAB 6 - LIAS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

goto Init_reg<br />

;**********************************************************************<br />

; ROUTINE D'INTERRUPTION *<br />

;**********************************************************************<br />

org 0x004<br />

; sauvegar<strong>de</strong> <strong>de</strong>s registres principaux<br />

movwf w_temp;<br />

swapf STATUS,w<br />

movwf status_temp<br />

; Adresse d'interruption<br />

; Sauvegar<strong>de</strong> registre W<br />

; Swap Status et sauvegar<strong>de</strong> dans W<br />

; Sauvegar<strong>de</strong> Status dans la ram<br />

; Test si l'interruption est issue du TIMER0<br />

; Ce test est "inutile" car nous n'avons autorisé qu'une seule interruption<br />

btfss INTCON, TOIF ; Test si le Flag est à 1 (= Débor<strong>de</strong>m<strong>en</strong>t)<br />

goto restoreg<br />

; Si le test est faux, je ne traite pas l'interruption et je restaure les<br />

registres<br />

; traitem<strong>en</strong>t <strong>de</strong> l'interruption<br />

call inttmr0<br />

; Un call est une routine qui permet <strong>de</strong> rev<strong>en</strong>ir à l'emplacem<strong>en</strong>t du<br />

programme<br />

; un goto ne revi<strong>en</strong>t pas<br />

clrf TMR0<br />

; TMR0 vaut 255, je l'annule sous risque <strong>de</strong> remettre mon<br />

flag à 1<br />

; restauration du flag<br />

bcf INTCON,2 ; Je repositionne le Flag informant le dépassem<strong>en</strong>t à 0<br />

; restauration <strong>de</strong>s registres<br />

restoreg<br />

swapf status_temp, w ; On restaure le registre STATUS<br />

movwf STATUS<br />

swapf w_temp,f<br />

; Inversion <strong>de</strong>s bits poids forts/poids faible du registre <strong>de</strong><br />

sauvegar<strong>de</strong> w_temp sans modifier le status<br />

swapf w_temp,w<br />

; Re-inversion W

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!