I have connected 7segment display to PORTB (RB1-RB7), RB0 is external interrupt pin which is turned on

to display number 8, I wrote 0b11111110, so what will happen to external interrupt when I write 0 on 0th bit

 unit8_t sevenSegDigit[10]={
 0b11111110,  // 0
 0b10010000,  // 1
 0b11010100,  // 2

this will create any problem ?

any solution to create a lookup table like above code without writing the interrupt bit/pin ? PIC16F876A

  • \$\begingroup\$ It depends on the interrupt configuration. If it is falling edge triggered or low level triggered then when setting the pin from 1 to 0 can trigger an interrupt. \$\endgroup\$ Sep 13, 2017 at 7:49
  • \$\begingroup\$ @BenceKaulics any solution to create a lookup table like above code without writing the iterrupt bit/pin ? \$\endgroup\$
    – masternone
    Sep 13, 2017 at 9:09
  • 1
    \$\begingroup\$ 2 solutions: 1. do not write to PB0, instead of PORTB = 0bxxxxxxx0 do: PORTB =| 0bxxxxxxx0 (not changing last bit this time) 2. Disable interrupt \$\endgroup\$
    – smajli
    Sep 13, 2017 at 11:32

1 Answer 1


In most chips, you can trigger an interrupt from software. Here's an excerpt from the ATMega328 datasheet:

Observe that, if enabled, the interrupts will trigger even if the INT0 and INT1 or PCINT23...0 pins are configured as outputs. This feature provides a way of generating a software interrupt.

So if you will change the value of the bit corresponding to your interrupt pin in PORTx register, it will trigger an interrupt. You can, of course, set when the interrupt will trigger - on change, rising or falling.

I recommend reading your chip's datasheet as well to see what the manufacturer says about this.

If you want to avoid this situation altogether, you can use a different PORTx register for outputs if you need to utilize all 8 pins in PORTB, or just leave the interrupt bit alone and not change its values.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.