Opened 12 months ago

Last modified 9 months ago

#32 assigned defect

ATMEGA8A: Incorrect use of the 'missed_cm' variable.

Reported by: Pawel Owned by: dsl
Priority: major Milestone: MCUSim-0.2
Component: avr Keywords: planned-in-0.2
Cc: dsl

Description

In the file avr_m8a.c, variable 'missed_cm' is set in the if statement then it's reset in the if statement with the same condition.

code:

if ((stop_mode == 0U) && (presc != tc2_presc)) {

/* We may have TC2 enabled with Compare Match missed. */
if ((tc2_presc == 0U) && (DM(TCNT2) > DM(OCR2))) {

missed_cm = 1;

}

tc2_presc = presc;
ocr2_buf = mcu->dm[OCR2];
/* Should we really clean these ticks? */
tc2_ticks = 0;

}
if ((stop_mode == 0U) && (missed_cm != 0U) && (presc == tc2_presc)) {

missed_cm = 0;

}

Change History (7)

comment:1 Changed 12 months ago by dsl

Keywords: planned-in-0.2 added; ATMEGA8A BUG missed_cm removed
Milestone: MCUSim-0.2
Status: newassigned
Summary: [BUG] ATMEGA8A: Wronge use of the 'missed_cm' variable.ATMEGA8A: Incorrect use of the 'missed_cm' variable.

comment:2 Changed 12 months ago by dsl

Cc: Dmitry Salychev added; Dm removed

comment:3 Changed 12 months ago by dsl

Cc: dsl added; Dmitry Salychev removed

comment:4 Changed 12 months ago by dsl

A "missed_cm" flag is supposed to be a way to guarantee symmetry around a
BOTTOM value of the Timer/Counter2. One of the cases is the timer starts
counting from a value higher than the one in OCR2, and for that reason misses
the Compare Match and hence the OCn change that would have happened on the
way up.

See detailed description in "22.7.4. Phase Correct PWM Mode" and
"Figure 22-7 Phase Correct PWM Mode, Timing Diagram" of the ATmega8A datasheet.

comment:5 Changed 11 months ago by dsl

Milestone: MCUSim-0.2MCUSim 0.2

Milestone renamed

comment:6 Changed 11 months ago by dsl

Milestone: MCUSim 0.2mcusim 0.2

Milestone renamed

comment:7 Changed 9 months ago by dsl

Milestone: mcusim 0.2MCUSim-0.2

Milestone renamed

Note: See TracTickets for help on using tickets.