From af6fea4b9358157ddcf784692e159808a01e37ce Mon Sep 17 00:00:00 2001 From: Jochen Kiemes Date: Sat, 6 Feb 2021 00:38:06 +0100 Subject: [PATCH] test to fix foc causing erroneous interrupt --- simavr/sim/avr_timer.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/simavr/sim/avr_timer.c b/simavr/sim/avr_timer.c index 827261d..ff2c352 100644 --- a/simavr/sim/avr_timer.c +++ b/simavr/sim/avr_timer.c @@ -74,10 +74,13 @@ static avr_cycle_count_t avr_timer_comp( avr_timer_t *p, avr_cycle_count_t when, - uint8_t comp) + uint8_t comp, + uint8_t raise_interrupt) { avr_t * avr = p->io.avr; - avr_raise_interrupt(avr, &p->comp[comp].interrupt); + if (raise_interrupt) { + avr_raise_interrupt(avr, &p->comp[comp].interrupt); + } // check output compare mode and set/clear pins uint8_t mode = avr_regbit_get(avr, p->comp[comp].com); @@ -149,7 +152,7 @@ avr_timer_compa( avr_cycle_count_t when, void * param) { - return avr_timer_comp((avr_timer_t*)param, when, AVR_TIMER_COMPA); + return avr_timer_comp((avr_timer_t*)param, when, AVR_TIMER_COMPA, 1); } static avr_cycle_count_t @@ -158,7 +161,7 @@ avr_timer_compb( avr_cycle_count_t when, void * param) { - return avr_timer_comp((avr_timer_t*)param, when, AVR_TIMER_COMPB); + return avr_timer_comp((avr_timer_t*)param, when, AVR_TIMER_COMPB, 1); } static avr_cycle_count_t @@ -167,7 +170,7 @@ avr_timer_compc( avr_cycle_count_t when, void * param) { - return avr_timer_comp((avr_timer_t*)param, when, AVR_TIMER_COMPC); + return avr_timer_comp((avr_timer_t*)param, when, AVR_TIMER_COMPC, 1); } static void @@ -725,7 +728,7 @@ static void avr_timer_write_foc(struct avr_t * avr, avr_io_addr_t addr, uint8_t for (int compi = 0; compi < AVR_TIMER_COMP_COUNT; compi++) { if ((addr == p->comp[compi].foc.reg) && (v & (1 << p->comp[compi].foc.bit))) { - avr_timer_comp(p, avr->cycle, compi); + avr_timer_comp(p, avr->cycle, compi, 0); } } } -- 2.39.5