AVR Studio Error or my errror? (Timer0 and Timer1 crosstalk)

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Device ATMega128
Studio: 4.11, Build 410, SP3

I have the following problem:

When simulating, I get unexpected Timer-0 Overlow interrupts.
This starts happening, as sonn I enable PWM on Timer 1.
The Interrupt occures, but Timer0 has not been overflow:

The timer configured to elapse every 5ms, the first interrupt
is:
after approx. 1 ms, as soon as the TCCR1A matches TCNT1

The attached screenshot is shows the moment, where the ISR has been entered.

In this case, the TIFR is not zero anymore, but any bit associated to Timer 0 (including TOV0) is zero....

Is this "crosstalk" my fault (wrong config) or AVR's?

Here some snippet to show the config:

PWM

void InitPWM(void)
{
    TCCR1A = 0xFC + _BV(WGM10) ; // Non inverting PWM connected to OC1x, mode is "Phase correct PWM", "8 bit"
    TCCR1B = _BV(CS02); // Prescaler to 256 -->  120 Hz
    
    /* Init with 25% */ 
    
    cli();
    OCR1A = 0xFF / 4;
    OCR1B = 0xFF / 4;
    OCR1C = 0xFF / 4;
    sei();   
}

Timer0 Init (and start of ISR)

void InitTimer0(void)
{
    
    /* Timer 0 Config... approx every 5 ms... */
    TCCR0 = _BV(CS02) + _BV(CS01) + _BV(CS00); /* Normal mode, OC0 discconnected, Prescaler = 1024, Reload 80 (dez)*/
    TCNT0 = 256-79;
    TIMSK = _BV(TOIE0);
 
}

/** Timer 0 Overflow ISR */

SIGNAL(SIG_OVERFLOW0)
{
     
    TCNT0 = 256-79;
    
    if(StartupDelay)
    { 
        StartupDelay--;
        return;
    }
  
   // some problem-irrelevant code (StartupDelay != 0)
 }
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It does look like a simulator bug. Also it is a new one - 4.11 (with no SP) does not behave like that.

On the other hand the Known issues for the simulator has this :

Quote:
16-bit Timer/Counters on all devices have several problems with PWM, prescaler and output compare. Output compare registers are not buffered properly.

/Lars