//gestionnaire d'interruption
//------------------------------
// High priority interrupt vector
#pragma code InterruptVectorHigh = 0x08
void InterruptVectorHigh (void)
{
_asm
goto InterruptHandlerHigh //jump to interrupt routine
_endasm
}
// High priority interrupt routine
#pragma code
#pragma interrupt InterruptHandlerHigh
void InterruptHandlerHigh ()
{
static char i ; // doit etre statique pour conserver sa valeur entre les IT
static char C ;
static int T;
//======== SERIAL======================
if(PIR1bits.RCIF) // si un car arrive
{
C =ReadUSART(); // le lire => RAZ RCIF
if(RCSTAbits.FERR || RCSTAbits.OERR)
{
RCSTAbits.CREN = 0 ;
RCSTAbits.CREN= 1 ;
}
// if you want an Echo
while(BusyUSART()); // par sécurité
WriteUSART(C);
if( C == BS) // correct the buffer (Back Shift)
{
if(i>0){
i--; }
}
else {
if(C != CR && i<MAX_LEN) // if not <CR> touch or size less than maximum of buffer
{
buffer[i++]=C ; // store it into the buffer
}else
{
buffer[i]='\0'; // fin de chaîne si CR
i=0;
received =1; // flag to test inside the main .. for displaying the result on LCD or Terminal
}
}
}
}