From 6627a606d741d6f9701297ab0127a5e131e2a225 Mon Sep 17 00:00:00 2001 From: Vladimir Garistov Date: Wed, 15 Nov 2023 17:28:46 +0200 Subject: [PATCH] Added timer simulation and an example of code that breaks without volatile specifier --- Examples/interrupts/volatile/volatile.ino | 29 + Examples/timer/Timer_1.circ | 859 ++++++++++++++++++++++ 2 files changed, 888 insertions(+) create mode 100644 Examples/interrupts/volatile/volatile.ino create mode 100644 Examples/timer/Timer_1.circ diff --git a/Examples/interrupts/volatile/volatile.ino b/Examples/interrupts/volatile/volatile.ino new file mode 100644 index 0000000..fec265c --- /dev/null +++ b/Examples/interrupts/volatile/volatile.ino @@ -0,0 +1,29 @@ +#define BTN_PIN 2 + +void btn_press(void); + +uint8_t btn_cnt = 0; +uint8_t * ptr_a = &btn_cnt; + +void setup() +{ + pinMode(BTN_PIN, INPUT_PULLUP); + attachInterrupt(digitalPinToInterrupt(BTN_PIN), btn_press, FALLING); + Serial.begin(9600); +} + +void loop() +{ + while (1) + { + if (*ptr_a == 5) + { + Serial.println("TEST"); + } + } +} + +void btn_press(void) +{ + *ptr_a+=1; +} diff --git a/Examples/timer/Timer_1.circ b/Examples/timer/Timer_1.circ new file mode 100644 index 0000000..3f14742 --- /dev/null +++ b/Examples/timer/Timer_1.circ @@ -0,0 +1,859 @@ + + + This file is intended to be loaded by Logisim-evolution v3.8.0(https://github.com/logisim-evolution/). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.39.2