
program electronique_pic_tuto_base_interrupt_001a;
procedure Interrupt;
begin
// action à exécuter lorsque l'interruption survient
end;
// main program
begin
Init;
while true do
begin
// code à exécuter "hors interruptions"
end;
end.
procedure Interrupt;
begin
if INTCON.T0IF = 1 then
begin
// action à exécuter lorsque l'interruption du timer 0 survient
INTCON.T0IF := 0; // remise à zéro du statut de l'interruption
end;
end;
procedure Interrupt;
begin
if INTCON.T0IF = 1 then
begin
// action N° 1, à exécuter lorsque l'interruption du timer 0 survient
INTCON.T0IF := 0; // remise à zéro du statut de l'interruption
end;
if INTCON.RBIF = 1 then
begin
// action N° 2, à exécuter lorsque l'interruption des entrées du port B survient
INTCON.RBIF := 0; // remise à zéro du statut de l'interruption
end;
end;
program electronique_pic_tuto_base_interrupt_001b;
procedure Init;
begin
CMCON := %00000111; // comparators OFF
TRISIO.0 := 0; // GPIO configuré en sortie
ANSEL.ANS0 := 0; // GPIO configuré en sortie numérique
INTCON.GIE := 1; // activation générale (globale) des interruptions
INTCON.T0IE := 1; // activation interruption timer 0
INTCON.RBIE := 1; // activation interruption entrées port B
end;
procedure Interrupt;
begin
if INTCON.T0IF = 1 then
begin
// action N° 1, à exécuter lorsque l'interruption du timer 0 survient
INTCON.T0IF := 0; // remise à zéro du statut de l'interruption
end;
if INTCON.RBIF = 1 then
begin
// action N° 2, à exécuter lorsque l'interruption des entrées du port B survient
INTCON.RBIF := 0; // remise à zéro du statut de l'interruption
end;
end;
// main program
begin
Init;
while true do
begin
// code à exécuter "hors interruptions"
end;
end.