Академический Документы
Профессиональный Документы
Культура Документы
Elemento
L1 led
L2 led
L5 led
buzz bocina
Prioridad
Alta
Alta
Baja
Baja
Terminal
Lata4 (RA4)
Lata5 (RA5)
Lata3 (RA3)
Lata2 (RA2)
Prof. S. Saucedo
de Configuracion *******************************/
= 5
// (20 MHz crystal on PICDEM FS USB board)
= OSC1_PLL2
= 2
// Clock source from 96MHz PLL/2
= HSPLL_HS
= OFF
= OFF
= OFF
= ON
= 3
= ON
//USB Voltage Regulator
= OFF
= 32768
= ON
= OFF
= OFF
= ON
= ON
= OFF
= OFF
// Dedicated In-Circuit Debug/Programming
= OFF
// Extended Instruction Set
= OFF
= OFF
= OFF
= OFF
= OFF
= OFF
Gpo 6CM9_2013
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
config
config
config
config
config
config
config
config
config
config
config
config
WRT0
WRT1
WRT2
WRT3
WRTB
WRTC
WRTD
EBTR0
EBTR1
EBTR2
EBTR3
EBTRB
=
=
=
=
=
=
=
=
=
=
=
=
OFF
OFF
OFF
OFF
ON
OFF
OFF
OFF
OFF
OFF
OFF
OFF
L1
L2
L5
buzz
L3
L4
LATAbits.LATA4
LATAbits.LATA5
LATAbits.LATA3
LATAbits.LATA2
LATCbits.LATC0
LATCbits.LATC1
Prof. S. Saucedo
Gpo 6CM9_2013
Prof. S. Saucedo
******************
Gpo 6CM9_2013
PIR1bits.TMR1IF = 0;
TMR1H = TIMER1H_VAL;
TMR1L = TIMER1L_VAL;
}
}
//**************************************************************************
void ConfigPuertos(void)
{
ADCON1 |= 0x0F;
TRISA=0B00000000;
LATA = 0x20;
TRISB = 0xFF;
}
void ConfigINT0(void)
{
INTCON2bits.INTEDG0 = 0; // activada por flanco descendente
INTCON2bits.RBPU = 0;
// activa las resistencias de subida
INTCON |= 0B10010000;
// Habilita INT0
}
/************************ PROGRAMA PRINCIPAL ***************************/
/************************************************************************/
void main (void)
{
ConfigPuertos();
RCONbits.IPEN=1; // habilita prioridades de interr
INTCON2bits.TMR0IP=0;
//mInitAllSwitches();
ConfigINT0();
configTemp0();
configPortb();
configTemp1();
cuenta = 0;
while (1)
{
copia = cuenta;
buzz = (copia&&17 == 17);
}
}
//************************************************************************
void configTemp0(void)
{
INTCONbits.TMR0IF = 0;
TMR0H = TIMER0H_VAL;
TMR0L = TIMER0L_VAL;
T0CON = 0b10000111; //0x87 o 0x97
INTCON |= 0x60;
}
void configTemp1(void)
{
PIR1bits.TMR1IF = 0; // limpia bit de interr.
TMR1H = TIMER1H_VAL;
TMR1L = TIMER1L_VAL;
T1CON = 0b00001101; //0x0D
PIE1bits.TMR1IE = 1;
Prof. S. Saucedo
Gpo 6CM9_2013
Prof. S. Saucedo
Gpo 6CM9_2013