Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static inline void initTimer0(void) {
- // Timer Counter Control Register B
- // Must b4 /64 or more for ISR timing
- TCCR0B |= (1 << CS00) | (1 << CS01);
- // Timer Counter Interrupt Mask Register
- // both output compare interrupts
- TIMSK0 |= ((1 << OCIE0A) | (1 << OCIE1B));
- // Timer Counter Overflow Interrupt Enable
- TIMSK0 |= (1 << TOIE0);
- sei();
- }
- /* Timer/Counter0 Overflow */
- // called whenever TCNT0 overflows
- ISR(TIMER0_OVF_vect) {
- PORTB |= (1 << 0);
- OCR0A = brightnessA;
- }
- // ISR fired when a match occurs
- ISR(TIMER0_COMPA_vect) {
- PORTB ^= (1 << 0);
- }
- int main(void)
- {
- setup();
- int d = 10;
- while (1)
- {
- for (int i = 0; i < 255; i++) {
- _delay_ms(d);
- brightnessA = i;
- }
- }
- }
- DDRB |= 1 << 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement