18F45K22 - external interruption

Asked

Viewed 35 times

1

One led is flashing every half second, while the other will only be access when I send a low level signal to RB0 on the microcontroller, I wonder if there is something missing, because I did exactly as I was asked and even then, only led by Polling is flashing, the interruption does not occur: follows below the code in C:

bit  controle;
void interrupt()      
{
  if(INT0IF_bit)
  {
    controle = ~controle;
    INT0IF_bit = 0;
    if(controle) RA0_bit = 1;
    else RA0_bit = 0;
  }
}

void main()
{
  TRISA = 0xFC; 
  TRISB = 0xFF; 
  PORTA = 0xFC;
  PORTB = 0xFF;
  IPEN_bit = 1; 
  RBIP_bit = 1;
  INTCON = 0x90; 
  INTCON2 = 0x00;
  controle = 0;

  while(1)
  {    
    //  Lógica para fazer LEd piscar por Polling..
    RA1_bit = 0x01;
    delay_ms(TempoPolling);
    RA1_bit = 0x00;
    delay_ms(TempoPolling);
    // Fim da Lógica
}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.