Skip to content

Commit

Permalink
Something resembling finished
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Jacoby committed Jun 7, 2012
1 parent 2adc33f commit 502c18c
Showing 1 changed file with 35 additions and 12 deletions.
47 changes: 35 additions & 12 deletions t45_pwm/blink.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,32 @@
*
*/

/* Interrupt Code
*
* This bit of code is executed everytime something magnificent happens
*
*/

ISR(SIG_OUTPUT_COMPARE0A) {



}




int main(void) {

/* GTCCR: General Timer/Counter Control Register
*
* Turn that sucker on and off
*
*/

// Might as well be off while we're setting up, eh?
GTCCR &= ~_BV(TSM);

/* TCCR0A: Timer/Counter Control Register A
*
* Set this register to control what happens on the output pin,
Expand Down Expand Up @@ -60,29 +83,29 @@ int main(void) {

OCR0A = 0xFF;

/* We're going to want to trigger some events synchronously with the timer,
* so we'll set the TIMSK: Timer/Counter Interrupt Mask here.
*
*/

TIMSK |= _BV( OCIE1A )

// We want PWM output on PB0 -- so set it to an output

// We want the PWM output on PB0 -- so it's got to be set as an output
DDRB |= (1 << PB0);



// This enables global interrupts now and forever--until they're turned off
sei();

// Turn the timer on, stand back, and do nothing.
GTCCR = _BV(TSM);

while(1) {
cycle_pin(PB0);
cycle_pin(PB1);
cycle_pin(PB2);

}

return 0;
}

// Cycle @pin for @delay milliseconds
void cycle_pin(int pin) {

PORTB |= (1 << pin);
_delay_ms(DELAY);
PORTB &= ~(1 << pin);

}

0 comments on commit 502c18c

Please sign in to comment.