timer 3
This commit is contained in:
		
							parent
							
								
									29de37d5c0
								
							
						
					
					
						commit
						0f867796de
					
				
					 2 changed files with 18 additions and 151 deletions
				
			
		| 
						 | 
				
			
			@ -29,24 +29,24 @@ volatile uint32_t timer_count = 0;
 | 
			
		|||
void timer_init(void)
 | 
			
		||||
{
 | 
			
		||||
    // Timer0 CTC mode
 | 
			
		||||
    TCCR1A = 0x02;
 | 
			
		||||
    TCCR0A = 0x02;
 | 
			
		||||
 | 
			
		||||
#if TIMER_PRESCALER == 1
 | 
			
		||||
    TCCR1B = 0x01;
 | 
			
		||||
    TCCR0B = 0x01;
 | 
			
		||||
#elif TIMER_PRESCALER == 8
 | 
			
		||||
    TCCR1B = 0x02;
 | 
			
		||||
    TCCR0B = 0x02;
 | 
			
		||||
#elif TIMER_PRESCALER == 64
 | 
			
		||||
    TCCR1B = 0x03;
 | 
			
		||||
    TCCR0B = 0x03;
 | 
			
		||||
#elif TIMER_PRESCALER == 256
 | 
			
		||||
    TCCR1B = 0x04;
 | 
			
		||||
    TCCR0B = 0x04;
 | 
			
		||||
#elif TIMER_PRESCALER == 1024
 | 
			
		||||
    TCCR1B = 0x05;
 | 
			
		||||
    TCCR0B = 0x05;
 | 
			
		||||
#else
 | 
			
		||||
#   error "Timer prescaler value is NOT vaild."
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    OCR1A = TIMER_RAW_TOP;
 | 
			
		||||
    TIMSK1 = (1<<OCIE1A);
 | 
			
		||||
    OCR0A = TIMER_RAW_TOP;
 | 
			
		||||
    TIMSK0 = (1<<OCIE0A);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline
 | 
			
		||||
| 
						 | 
				
			
			@ -111,7 +111,7 @@ uint32_t timer_elapsed32(uint32_t last)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
// excecuted once per 1ms.(excess for just timer count?)
 | 
			
		||||
ISR(TIMER1_COMPA_vect)
 | 
			
		||||
ISR(TIMER0_COMPA_vect)
 | 
			
		||||
{
 | 
			
		||||
    timer_count++;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue