void main(void)
{
// Set Up PortA
ADCON0 = 0x00; // Disable the AD converter
ADCON1 = 0x0F; // 0x0F = Set all port A,B to digital
TRISA = 0b00000000; // Setup PORTA as Output
// Set up PortB as Keypad
TRISB = 0b11100000;
// Set up PortB Interrupt
INTCON2bits.RBPU = 0; // Enable Pull up resistors at PORTB
RCONbits.IPEN = 1; // Enable INT Priority
INTCON2bits.RBIP = 1; // Set PORTB INT as High Priority INT
INTCONbits.PEIE = 1; // Enable Peripheral INT
INTCONbits.RBIE = 1; // Enable PORTB INT
INTCONbits.GIEH = 1; // Enable All INT
INTCONbits.RBIF = 0; // Clear PORTB INT Flag
while(1)
{
LATAbits.LATA0 = 0; // RA0=0 LED=OFF Scope=50ms
Delay10KTCYx(1);
LATAbits.LATA0 = 1; // RA0=1 LED=ON Scope=1
Delay10KTCYx(1) ; // 10,000 x 1 x (4 x 0.05us) = 2ms
// Scope = 2ms
} // End Main Loop
} // End Main |