sajay
Newbie level 4

Dear Guys,
I got below code on other forum, my question is how to enable PORTB RB1, RB2, RB3, RB4, below code only enable for PORTB RB0 (if (INTCON.INTF) ).
I mean is when RB1 toggle then PORTC & PORTD ON, one more toggle PORTC & PORTD OFF.
I got below code on other forum, my question is how to enable PORTB RB1, RB2, RB3, RB4, below code only enable for PORTB RB0 (if (INTCON.INTF) ).
I mean is when RB1 toggle then PORTC & PORTD ON, one more toggle PORTC & PORTD OFF.
Code:
int cnt = 127;
void main() {
TRISB = 0xFF;
TRISC = 0X00;
PORTC = 0x00;
TRISD=0x00;
PORTD=0x40;
ADCON1 = 0x7F; // all pins digital
0xD0; // gie i int enabled
OPTION_REG = 0x00;
PWM1_Init(5000); // pwm freq = 5000hz
PWM1_Set_Duty(cnt);
PWM1_Start();
while (1)
{
}
}
void interrupt (void)
{
if (INTCON.INTF)
{
//motor changes direction on each interrupt:
PORTD.f7=~PORTD.f7; // D.f7=1 (motor turns clockwise);
PORTD.f0=~PORTD.f0; // LED on D.f1 changes state on each interrupt
INTCON.INTF = 0; // reset int flag
}
if (INTCON.INTF)
{
//motor changes direction on each interrupt:
PORTD.f6=~PORTD.f6; // D.f7=1 (motor turns clockwise);
PORTD.f1=~PORTD.f1; // LED on D.f1 changes state on each interrupt
INTCON.INTF = 0; // reset int flag
}
}