program clignotant_001; var RedOrBlue : Byte; procedure init(); begin TRISA := %00000000; // Configuration de la broche RA0 comme entrée PORTA := %00000000; // On met toutes les sorties du PORTA à "0" TRISB := %00000000; // Configuration du PORTB comme sortie PORTB := %00000000; // On met toutes les sorties du PORTB à "0" CMCON := 0x07; //ANSEL := %00000000; // Configuration du mode numérique (digital) INTCON.GIE := 1; // On active les interruptions générales INTCON.PEIE := 1; // On active les interrutpions périphériques TMR1ON_bit := 1; T1CKPS0_bit := 0; T1CKPS1_bit := 0; TMR1CS_bit := 0; TMR1IE_bit := 1; // On active les interruptions du Timer0 TMR1IF_bit := 0; // Le drapeau de débordement est à zéro TMR1L := 0x00; // On initialise le Compteur du Timer1 à zéro! TMR1H := 0x00; RedOrBlue := 0; end; procedure interrupt(); begin if ((TMR1IF_bit = 1) and (RedOrBlue = 1)) then begin RedOrBlue := 0; delay_ms(200); TMR1IF_bit := 0; end; if ((TMR1IF_bit = 1) and (RedOrBlue = 0)) then begin RedOrBlue := 1; delay_ms(200); TMR1IF_bit := 0; end; end; begin init(); while true do begin if (RedOrBlue = 1) then begin LATB := 0; LATA := 0xFF; delay_ms(50); LATA := 0x00; RedOrBlue := 1; delay_ms(50); end; if (RedOrBlue = 0) then begin LATA := 0; LATB := 0xFF; delay_ms(50); LATB := 0x00; RedOrBlue := 0; delay_ms(50); end; end; end.