ISR wird nicht aufgerufen FastPWM Attiny2313

Gast #3302835
Lesenswert?
• ▲
▼
Ich werde gleich wahnsinnig. Ich nutze den Timer0 zur FastPWM und würde 
gerne in den ISR der entsprechenden Interrupts das Output Compare 
Register auf einen neuen Wert setzen. Leider springe ich nie in die 
ISRs. Es ist sicher irgendwas blödes, aber ich bin wohl grade 
betriebsblind. Ich habe ein Testprogramm eingefügt. In dem Testprogramm 
setze ich nicht das OCR neu, sondern einen Port Pin auf high.

int main(void)
{
  cli();
  /* OC0A is PIN PB2= PIN 14 */
  DDRB = 0xFF;
  DDRD = 0xFF;

    TCCR0A  =0;
  /* Clear OC0A on Compare Match, set OC0A at BOTTOM --> non inverting 
mode*/
  TCCR0A |= (1<<COM0A1);
  /*Fast PWM*/
  TCCR0A |= (1<<WGM00);
  TCCR0A |= (1<<WGM01);

  TCCR0B=0;
  /* clkI/O/1024 (From prescaler) */
  TCCR0B |= (1 << CS02);
  TCCR0B |= (1 << CS00);

  TIMSK=0;
  /* Timer/Counter0 Output Compare Match A Interrupt Enable */
  TIMSK |= (1 << OCIE0A);
  /* Timer/Counter0 Overflow Interrupt Enable */
  TIMSK |= (1 << TOIE0);

  /* half of the time on and half of the time off */
  OCR0A = 128;

  /*PORTD |= (1 << PORTD6);*/

  sei();
  }

  ISR(TIMER0_COMPA_vect)
  {
    PORTD |= (1 << PORTD6);
  }

  ISR(TIMER0_OVF_vect)
  {
    PORTD |= (1 << PORTD6)  ;
  }

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren