void init() { AD1PCFG = 0xFFFF; // Utilisation des entrées en numériques TRISB = 0x0000; // Les broches du PORTB sont configurées en sorties LATB = 0x0000; // Initialise toutes les sorties du PORTB à l’état logique BAS PORTB = 0x0000; // On fixes les sorties à l’état zéro EnableInterrupts(); // Activations des interruptions IVT ON__T2CON_bit = 1; // On active le timer 2 SIDL_T2CON_bit = 0; TCKPS0_T2CON_bit = 1; // | TCKPS1_T2CON_bit = 1; // | prescaler sur 256 TCKPS2_bit = 1; // | T32_bit = 0 ; // Timer2 config sur 16 bits TCS_bit = 0; // Horloge interne (Quartz OSC1 et OSC2) 8MHZ T2IE_bit = 1; // On active les interrutpions du Timer2 T2IF_bit = 0; // Drapeau d’interrutpion baissé T2IP0_bit = 1; // | T2IP1_bit = 1; // | pritorité 7 de l’interruption du timer 2 T2IP2_bit = 1; // | TMR2 = 0x0000; // Le réglage à zéro le Timer2 c’est mieux pour commencer… } void Timer2() iv IVT_TIMER_2 // Interrutpion timer3 priorité 7 ilevel 7 { if (T2IF_bit==1) //T2IF représente les 256 coups d’horloge du timer2 { delay_ms(1000); LATB.RB4 = 1; // Led rouge allumée interruption en cours… LATB.RB1 = 0; // Led verte éteinte programme principale arrêté delay_ms(1000); LATB.RB4 = 0; // Led rouge éteinte fin de l’interruption T2IF_bit = 0; // On sort de l’interruption } } void main() { init(); // Initialisation du Mini-32 while (1) { LATB.RB1 = 1; // Led verte allumée programme principale en cours… } }