#!/usr/local/bin/php interruptions [GeWiki]
 
//arlotto 2007 : Démonstration des interruptions sur 18F4520
// L'it overflow Timer3 inverse RB1 tout les 4.Tosc.4.2^16
// soit 262.144ms
// L'it overflow Timer1 inverse RB2 tout les 4.Tosc.8.2^16
//soit 524.288 ms
// ici les it sont utilisées dans le mode pic18 
// avec priorité (RCONbits.IPEN = 1 )
// L'autorisation se fait par les bits GIE et PEIE de INTCON.
#include <p18cxxx.h> 
#include <timers.h>   // pour fonctions UART
 
// configuration PICDEM2+ quartz
#pragma config OSC = HS
#pragma config WDT = OFF
#pragma config LVP = OFF
#pragma config PBADEN = OFF
 
#define Button PORTBbits.RB0
#define GreenLed PORTBbits.RB1
#define RedLed   PORTBbits.RB2
 
 
//prototypes des gestionnaires d'interruption
void InterruptHandlerHigh (void);
void InterruptHandlerLow (void);
 
void main(void){
GreenLed= 0 ;
RedLed = 0 ;
TRISBbits.TRISB1=0;
TRISBbits.TRISB2=0;
OpenTimer1(TIMER_INT_ON    &
           T1_16BIT_RW     &
           T1_SOURCE_INT   &
	   T1_PS_1_8 	   &
	   T1_OSC1EN_OFF   &
	   T1_SYNC_EXT_OFF );
IPR1bits.TMR1IP=0;           // T1 basse priorité
 
OpenTimer3( TIMER_INT_ON  &
            T3_16BIT_RW   &
            T3_SOURCE_INT &
            T3_PS_1_4     &
            T3_SYNC_EXT_OFF );
IPR2bits.TMR3IP=1;         // T3 haute priorité
 
RCONbits.IPEN = 1;
INTCONbits.GIEL = 1 ; // autorisation low
INTCONbits.GIEH = 1 ; // autorisation high
 
for( ;; )
{
 
}
}
 
interruptions.txt · Dernière modification: 2015/04/27 16:54 (édition externe)
 
Sauf mention contraire, le contenu de ce wiki est placé sous la licence suivante:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki