Rackie
Newbie level 5
Hi Tahmid,
I am using mickoC and proteus for simulation.
Please tell me some advices regarding the problem of this code.
This code is for our traffic light project and I've got a problem with the push button(which is the interrupt), it won't work.
Thanks in advance...
I am using mickoC and proteus for simulation.
Please tell me some advices regarding the problem of this code.
This code is for our traffic light project and I've got a problem with the push button(which is the interrupt), it won't work.
Code:
int j=5;
int i=0;
int count = 0;
void interrupt(void)
{
for(i=0;i<5;i++)
{
PORTA = 0xFF;
PORTC = 0x00;
PORTD = 0x00;
Delay_ms(1000);
PORTC = 0x0F;
PORTD = 0xF0;
Delay_ms(1000);
count = count + 1;
}
PORTA = 0x00;
PORTC = 0xF0;
PORTD = 0x0F;
Delay_ms(5000);
for(j=5;j<10;j++)
{
PORTA = 0xFF;
PORTC = 0x00;
PORTD = 0x00;
Delay_ms(1000);
PORTC = 0xF0;
PORTD = 0x0F;
Delay_ms(1000);
count = count + 1;
}
PORTA = 0x00;
PORTC = 0x0F;
PORTD = 0xF0;
INTCON.INTF = 0; //You HAVE to clear interrupt flag
}
void main() {
INTCON.GIE = 1; //Enable Global Interrupt
INTCON.INTE = 1; //Enable RB0/INT external Interrupt
INTCON.PEIE = 0; //Disable all unmasked peripheral interrupt
OPTION_REG.INTEDG = 1; //Interrupt on rising edge
TRISB = 0xFF; //making portB as input
TRISC = 0x00; // making portC as output
TRISD = 0x00; // making portD as output
TRISA = 0x00; // making portA as output
ADCON1 = 7; //Disable ADC so that PORTA can be used for digital purpose
CMCON = 7; //Disable comparator
PORTC = 0x0F; // initially the red light is on for pedestrian
PORTD = 0xF0; //initially the green light is on for vehicle
PORTA = 0x00;
}
Thanks in advance...
Last edited by a moderator: