From: Jochen Kiemes Date: Fri, 5 Feb 2021 23:38:06 +0000 (+0100) Subject: test to fix foc causing erroneous interrupt X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=af6fea4b9358157ddcf784692e159808a01e37ce;p=sx%2Fsimavr.git test to fix foc causing erroneous interrupt --- 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); } } }