/* OK teste le 14/06/2011 sur 64MC802 */


#include <p33FJ64MC802.h>
#include <stdio.h>
#include <timer.h>



extern 	InitClock();
extern 	InitPORT_AND_PIN();
extern	InitTimer1();

// ATTENTION.......................
// POUR L'EXEMPLE : clock switch
_FOSCSEL(FNOSC_FRC);			
_FOSC(FCKSM_CSECMD & OSCIOFNC_OFF  & POSCMD_XT);	// Clock Switching is enabled and Fail Safe Clock Monitor is disabled
													// OSC2 Pin Function: OSC2 is Clock Output
													// Primary Oscillator Mode: XT Crystal
_FWDT(FWDTEN_OFF); 




int cpt1ms=0;
char flagIT=0;


void __attribute__((__interrupt__)) _T1Interrupt(void)
{
	PORTBbits.RB0=!PORTBbits.RB0;
	cpt1ms++;
	flagIT=1; // Pour traitement différé
    WriteTimer1(0);
    IFS0bits.T1IF = 0;    /* Clear Timer interrupt flag */
}  





int main(void) 
{
	
	InitClockSwitch();	// POUR L'EXEMPLE : clock switch
	InitPORT_AND_PIN();
 	InitTimer1();
	while(1) 
	{
	if (flagIT) // traitement différé
		{ 
		if ((cpt1ms%10)==0)
			{ 
			PORTBbits.RB1=!PORTBbits.RB1;
			}
		
		flagIT=0;
		}
	}

	return 0;
}


  	

