Simple controlling LED blinking in PIC18f4580

hi all..
i have a program to control LED blinking by using 2 inputs (buttons) on SK40C. But i fail. Can u take a look of my code's problem ? For your information, the blinking part is fine because i successfully test it without adding 'button input part'. Anyway, this code is build successfully.
i have a program to control LED blinking by using 2 inputs (buttons) on SK40C. But i fail. Can u take a look of my code's problem ? For your information, the blinking part is fine because i successfully test it without adding 'button input part'. Anyway, this code is build successfully.
- CODE: SELECT_ALL_CODE
#include<p18f4580.h>
//======================================================
//configuration bit
//===============================================================
#pragma config OSC = HS //HS Oscillator
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor disabled
#pragma config IESO = OFF // Oscillator Switchover mode disabled
#pragma config PWRT = OFF // PWRT disabled
#pragma config BOREN = OFF // Brown-out Reset disabled in hardware and software
#pragma config WDT = OFF // WDT disabled (control is placed on the SWDTEN bit)
#pragma config MCLRE = ON // MCLR pin enabled; RE3 input pin disabled
#pragma config PBADEN = OFF // PORTB<4:0> pins are configured as digital I/O on Reset
//#pragma config CCP2MX = PORTC // CCP2 input/output is multiplexed with RC1
#pragma config LVP = OFF // Single-Supply ICSP disabled
#pragma config XINST = OFF // Extended Instruction Set
//define
//================================================================
#define XTAL_FREQ 20MHZ //crystal frequency in MHZ
#define MHZ *1000L //number of KHZ in a MHZ
#define KHZ *1 //number of KHZ in a KHZ
#if XTAL_FREQ >= 12MHZ
#define DelayUs(x) { unsigned char _dcnt; \
_dcnt = (x)*((XTAL_FREQ)/(12MHZ)); \
while(--_dcnt != 0) \
continue; }
#else
#define DelayUs(x) { unsigned char _dcnt; \
_dcnt = (x)/((12MHZ)/(XTAL_FREQ))|1; \
while(--_dcnt != 0) \
continue; }
#endif
#define LED1 LATBbits.LATB6
#define LED2 LATBbits.LATB7
#define SW1 LATBbits.LATB0
#define SW2 LATBbits.LATB1
//Function Prototype
//================================================================
void DelayMs(unsigned char);
//Global Variable
//================================================================
//Main Function
//================================================================
void main(void)
{
unsigned char i;
TRISBbits.TRISB0 = 1; //configure PORTB I/O direction
TRISBbits.TRISB1 = 1; //configure PORTB I/O direction
TRISBbits.TRISB6 = 0; //configure PORTB I/O direction
TRISBbits.TRISB7 = 0; //configure PORTB I/O direction
LED1 = 0; //off LED1
LED2 = 0; //off LED2
while(1)
{
if(SW1==0)
{
for (i=10;i>0;i--) //looping for 8 times (4 times blinking)
{
LED1 ^= 1; //toggle LED
LED2 = 0;
DelayMs(1000); //delay 110ms
}
}
if(SW2==0)
{
for (i=8;i>0;i--)
{
LED2 ^= 1;
LED1 = 0;
DelayMs(1000);
}
}
}
}
//Function
//===========================================================
void DelayMs(unsigned char cnt) // delay function (mili second)
{
#if XTAL_FREQ <= 2MHZ
do {
DelayUs(996);
} while(--cnt);
#endif
#if XTAL_FREQ > 2MHZ
unsigned char i;
do {
i = 4;
do {
DelayUs(250);
} while(--i);
} while(--cnt);
#endif
}