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 fixe les sorties à l’état zéro EnableInterrupts(); // Activations des interruptions IVT ON__T2CON_bit = 1; // On active le Timer2 TCKPS0_T3CON_bit = 0; // | TCKPS1_T3CON_bit = 0; // | Timer3 réglé prescaler à 1:1 TCKPS2_T3CON_bit = 0; // | T32_bit = 1; // Mode 32 bits (Timer2 + Timer3) T3IP0_bit = 1; // | T3IP1_bit = 1; // | Priorité 7 T3IP2_bit = 1; // | T3IF_bit = 0; // On met le drapeau à zéro (Pas d’interrutpion) T3IE_bit = 1; // On active les interrutpion du Timer3 TMR2 = 0; // On commence à compter à partir de zéro TMR3 = 0; // On commence à compter à partir de zéro PR2 = 47300; PR3 = 1220; LATB.RB4 = 1; LATB.RB1 = 0; } void Timer2() iv IVT_TIMER_3 // Interrutpion timer3 priorité 7 ilevel 7 { if (T3IF_bit==1) //T3IF est à 1 lorsque Timer2/3 égale PR2/PR3 { LATB.RB4 = ~ LATB.RB4; // Led rouge LATB.RB1 = ~ LATB.RB1; // Led verte T3IF_bit = 0; } } void main() { init(); // Initialisation du Mini-32 while (1) { // On ne fait rien } }