Skip to content
Snippets Groups Projects
Select Git revision
  • 45a267a6ee0bd4d99e3fc0774a9cbcad9a63630f
  • 2024ss default
  • 2023ss
  • 2022ss
  • 2021ss protected
5 results

blink-07.c

Blame
  • blink-07.c 601 B
    #include <avr/io.h>
    #include <avr/interrupt.h>
    #include <stdint.h>
    
    uint8_t flag = 0;
    
    ISR (TIMER0_COMPB_vect)
    {
      static uint8_t counter = 0;
      if (counter++ == 0)
        flag = 1;
    }
    
    int main (void)
    {
      cli ();
      TCCR0B = (1 << CS01) | (1 << CS00);  /* Takt durch 64 dividieren */
      TIMSK0 = 1 << OCIE0B;  /* Interrupt einschalten */
      sei ();
      DDRB = 0xfe;   // Bit Nr. 0 als Input nutzen
      PORTB = 0x20;  // Bit Nr. 5 auf 1 setzen, alle anderen auf 0 ("digitalWrite" für alle 8)
      while (1)
        {
          if (flag)
            {
              PORTB ^= 0x20;
              flag = 0;
            }
        }
      return 0;
    }