[ create a new paste ] login | about

Link: http://codepad.org/OtyTFpLZ    [ raw code | fork ]

C, pasted on Sep 1:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/cpufunc.h>

static volatile uint8_t working = 0;

ISR (INT0_vect)
{
  working = 1;
  // doing this right here works
  // DDRB = _BV(PB0);
}

int
main (void)
{
  cli ();

  TCCR0A = _BV(WGM01) | _BV(COM0A0);
  OCR0A  = 7; // 36 kHz at F_CPU = 600 kHz
  TIMSK0 = _BV(OCIE0A);
  TCCR0B = _BV(CS00);

  PORTB = _BV(PB1); // button pull-up
  MCUCR = _BV(ISC01); // falling edge
  GIMSK = _BV(INT0);

  sei();

  while(1)
  {
    // does not seem to work here though.
    if (working == 1)
    {
      DDRB = _BV(PB0);
    }
    _NOP();
  }
}

======

CFLAGS = -Os -mmcu=attiny13a -std=c99 -Wall -Wextra -pedantic /usr/avr/lib/avr25/crttn13a.o -nostartfiles


Create a new paste based on this one


Comments: