1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
| #include <p18F452.h>
#include <delays.h>
#include <string.h>
#include <portb.h>
void tempo3(void);
#pragma config WDT = OFF
void configuration1(void);
void InterruptHandlerHigh (void);
void inter(void);
/////////////////////////////////////////////////
#pragma code InterruptVectorHigh = 0x08
void
InterruptVectorHigh (void)
{
_asm
goto InterruptHandlerHigh //jump to interrupt routine
_endasm
}
#pragma code
#pragma interrupt InterruptHandlerHigh
void
InterruptHandlerHigh ()
{
INTCONbits.RBIF = 0;
PORTBbits.RB1 = !PORTBbits.RB1;
T0CON=0b1000111;
TMR0H=0xB3;
TMR0L=0xB4;
}
//////////////////////////////////////////
#pragma code LowVector=0x18
void atInterruptlow(void)
{
_asm GOTO inter _endasm
}
#pragma code
#pragma interlow vect18
void inter()
{
INTCONbits.TMR0IF=0;
PORTBbits.RB2 = !PORTBbits.RB2;
}
//////////////////////////////////////
void tempo3(void)
{
T0CON=0b0000111;
TMR0H=0xB3;
TMR0L=0xB4;
INTCONbits.TMR0IE=1;// autorise IT débordement
RCONbits.IPEN=1;// Interruption prioritaires
INTCONbits.GIE=1;
}
////////////////////////////////////////////////////////////////////////////////////////////////
void main(void)
{
TRISBbits.TRISB4=1;
TRISBbits.TRISB2=0;
TRISBbits.TRISB3=0;
PORTBbits.RB4=1;
PORTBbits.RB2=0;
PORTBbits.RB3=0;
tempo3();
RCONbits.IPEN=1;// Interruption prioritaires
INTCONbits.GIE=1;
INTCON2bits.RBIP=1;
INTCONbits.PEIE = 1;
INTCONbits.RBIE = 1;
INTCONbits.RBIF = 0;
while(1)
{
T0CON=0b10000111;
PORTBbits.RB3 = 1;
}
} |
Partager