Open JarrettBillingsley opened 5 years ago
Quick patch:
diff --git a/simavr/sim/avr_ioport.c b/simavr/sim/avr_ioport.c
index e35b2de..287313d 100644
--- a/simavr/sim/avr_ioport.c
+++ b/simavr/sim/avr_ioport.c
@@ -154,7 +154,8 @@ avr_ioport_irq_notify(
if (p->r_pcint) {
// if the pcint bit is on, try to raise it
int raise = avr->data[p->r_pcint] & mask;
- if (raise)
+ int ddr = avr->data[p->r_ddr] & mask;
+ if (raise && ddr)
avr_raise_interrupt(avr, &p->pcint);
}
}
Once again, this code:
The output compare A is required to be enabled in this code because of a hardware bug in real ATTiny85. It uses PB1, but PB1 is set as an input with a pin change interrupt.
On real hardware, the pin change interrupt only (correctly) triggers on an external edge. However in simavr, the behavior of OCR1A toggles PB1's output value, which should be ignored, but instead triggers the interrupt as well.