Rev 32 | Rev 51 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 32 | Rev 37 | ||
---|---|---|---|
Line 74... | Line 74... | ||
74 | 74 | ||
Line 75... | Line 75... | ||
75 | 75 | ||
76 | // Timer/Counter 0 Control Register A |
76 | // Timer/Counter 0 Control Register A |
77 | 77 | ||
78 | // Normal Timer Counter Mode (Bits WGM02 = 0, WGM01 = 0, WGM00 = 0) |
78 | // Normal Timer Counter Mode (Bits WGM02 = 0, WGM01 = 0, WGM00 = 0) |
Line 79... | Line 79... | ||
79 | // OC0A disconnected (Bits COM0A1 = 0, COM0A0 = 0) |
79 | // OC0A disconnected (Bits COM0A1 = 0, COM0A0 = 0) |
Line 80... | Line 80... | ||
80 | // OC0B disconnected (Bits COM0B1 = 0, COM0B0 = 0) |
80 | // OC0B disconnected (Bits COM0B1 = 0, COM0B0 = 0) |
81 | TCCR0A &= ~((1<<COM0A1)|(1<<COM0A0)|(1<<COM0B1)|(1<<COM0B0)|(1<<WGM01)|(1<<WGM00)); |
81 | TCCR0A &= ~((1<<COM0A1)|(1<<COM0A0)|(1<<COM0B1)|(1<<COM0B0)|(1<<WGM01)|(1<<WGM00)); |
82 | 82 | ||
Line 83... | Line 83... | ||
83 | // Timer/Counter 0 Control Register B |
83 | // Timer/Counter 0 Control Register B |
84 | 84 | ||
85 | // set clock devider for timer 0 to SYSKLOCK/8 = 8MHz / 8 = 1MHz |
85 | // set clock devider for timer 0 to SYSKLOCK/8 = 8MHz / 8 = 1MHz |
Line 86... | Line 86... | ||
86 | // i.e. the timer increments from 0x00 to 0xFF with an update rate of 2.5 MHz |
86 | // i.e. the timer increments from 0x00 to 0xFF with an update rate of 2.5 MHz |
87 | // hence the timer overflow interrupt frequency is 2.5 MHz / 256 = 9.765 kHz |
87 | // hence the timer overflow interrupt frequency is 2.5 MHz / 256 = 9.765 kHz |
Line 88... | Line 88... | ||
88 | 88 | ||
89 | // divider 8 (Bits CS02 = 0, CS01 = 1, CS00 = 0) |
89 | // divider 8 (Bits CS02 = 0, CS01 = 1, CS00 = 0) |
90 | TCCR0B &= ~((1<<FOC0A)|(1<<FOC0B)|(1<<WGM02)|(1<<CS02)); |
90 | TCCR0B &= ~((1<<FOC0A)|(1<<FOC0B)|(1<<WGM02)|(1<<CS02)); |
91 | TCCR0B = (1<<CS01)|(0<<CS00); |
91 | TCCR0B = (1<<CS01)|(0<<CS00); |
Line 146... | Line 146... | ||
146 | 146 | ||
147 | 147 | ||
148 | // ----------------------------------------------------------------------- |
148 | // ----------------------------------------------------------------------- |
149 | uint16_t SetDelay (uint16_t t) |
149 | uint16_t SetDelay (uint16_t t) |
150 | { |
150 | { |
Line 151... | Line 151... | ||
151 | return(CountMilliseconds + t - 1); |
151 | return(CountMilliseconds + t - 1); |
152 | } |
152 | } |
153 | 153 | ||
Line 163... | Line 163... | ||
163 | uint16_t t_stop; |
163 | uint16_t t_stop; |
164 | t_stop = SetDelay(wait); |
164 | t_stop = SetDelay(wait); |
165 | while (!CheckDelay(t_stop)); |
165 | while (!CheckDelay(t_stop)); |
166 | } |
166 | } |
Line 167... | Line -... | ||
167 | - | ||
168 | - | ||
169 | - |