#include <p32xxxx.h>
#include <plib.h>
//Bits de configuración
#pragma config FNOSC = PRIPLL//Oscilador Principal con PPL
#pragma config POSCMOD = XT //Modo reloj principal XT (4Mz)
#pragma config FPBDIV = DIV_2//divisor Bus Periféricos
#pragma config FWDTEN = OFF//Wachdog deshabilitado
#pragma config FPLLODIV = DIV_1//Pos-Divisor PPL 1/1
#pragma config FPLLIDIV = DIV_1//Pre-Divisor PPL 1/1
#pragma config FPLLMUL = MUL_20// 20xPPL
unsigned short count = 0;
unsigned char cont_t2 = 0;
main()
{
unsigned short valor;
DDPCONbits.JTAGEN = 0; // disable JTAG port
CheKseg0CacheOn(); // enable the cache for max performance
mCheConfigure(CHECON | 0x30); // enable instruction prefetch
mBMXDisableDRMWaitState(); // disable RAM wait states
SYSTEMConfigPerformance(80000000L);
SYSTEMConfigWaitStatesAndPB(80000000L);
// Sobrescribo el PBDIV a 1:8 para este ejemplo, la sentencia anterior varia el PBDIV
mOSCSetPBDIV(OSC_PB_DIV_2); ////ESTA LINEA ES LA QUE PONE LAS COSAS EN ORDEN
TRISD = 0;
LATD = 0;
//_LATD0 = 0;
//_LATD14 = 1;
valor = 65468;
OpenTimer1(T1_ON | T1_PS_1_256, valor);
OpenTimer2(T2_ON | T2_PS_1_256, valor/2);
OpenTimer3(T3_ON | T3_PS_1_256, valor/15);
OpenTimer4(T4_ON | T4_PS_1_256, valor/4);
OpenTimer5(T5_ON | T5_PS_1_256, valor/25);
// 6. init interrupts
mT1SetIntPriority( 1);
mT2SetIntPriority( 1);
mT3SetIntPriority( 1);
mT4SetIntPriority( 1);
mT5SetIntPriority( 1);
mT1IntEnable( 1);
mT2IntEnable( 1);
mT3IntEnable( 1);
mT4IntEnable( 1);
mT5IntEnable( 1);
INTEnableSystemMultiVectoredInt();
while( 1)
{
}
} // main
void __ISR( _TIMER_1_VECTOR, ipl1) T1InterruptHandler( void)
{
_LATD14 = ~_LATD14;
mT1ClearIntFlag();
} //
void __ISR( _TIMER_2_VECTOR, ipl1) T2InterruptHandler(void)
{
_LATD11 = ~_LATD11;
mT2ClearIntFlag();
} //
void __ISR( _TIMER_3_VECTOR, ipl1) T3InterruptHandler(void)
{
_LATD8 = ~_LATD8;
mT3ClearIntFlag();
} //
void __ISR( _TIMER_4_VECTOR, ipl1) T4InterruptHandler(void)
{
_LATD4 = ~_LATD4;
mT4ClearIntFlag();
} //
void __ISR( _TIMER_5_VECTOR, ipl1) T5InterruptHandler(void)
{
_LATD0 = ~_LATD0;
mT5ClearIntFlag();
} //