You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an ISR that is attached to a timer alarm and called every two seconds. In this ISR there is a flag (AtomicBool) and a struct I want to update. I have the struct contained in a Mutex<RefCell<>>.
use esp_idf_svc::hal;
use hal::peripherals::Peripherals;
use hal::timer::TimerDriver;
use hal::timer::config;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Mutex;
use std::cell::RefCell;
I can change the flag (runs without COUNTER.lock().unwrap().borrow_mut().count += 1;), but get the following error when trying to increment the struct field "count":
Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0).
I know I am probably missing something important. The ISR works without trying to modify COUNTER. I am wondering how to safely mutate a struct in an ISR?
The text was updated successfully, but these errors were encountered:
I have an ISR that is attached to a timer alarm and called every two seconds. In this ISR there is a flag (AtomicBool) and a struct I want to update. I have the struct contained in a Mutex<RefCell<>>.
use esp_idf_svc::hal;
use hal::peripherals::Peripherals;
use hal::timer::TimerDriver;
use hal::timer::config;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Mutex;
use std::cell::RefCell;
static FLAG: AtomicBool = AtomicBool::new(false);
struct InterruptCount {
count: i32,
}
static COUNTER: Mutex<RefCell> = Mutex::new(RefCell::new(InterruptCount{count:1}));
fn increment_interrupt() {
hal::interrupt::free(|| {
FLAG.store(true, Ordering::Relaxed);
COUNTER.lock().unwrap().borrow_mut().count += 1;
});
}
I can change the flag (runs without COUNTER.lock().unwrap().borrow_mut().count += 1;), but get the following error when trying to increment the struct field "count":
Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0).
I know I am probably missing something important. The ISR works without trying to modify COUNTER. I am wondering how to safely mutate a struct in an ISR?
The text was updated successfully, but these errors were encountered: