Generation

generate functionSun, 16 Apr 2023

Crea un medidor de frecuencia

// frequency.c #include <avr/interrupt.h> #include <avr/io.h> // the prescaler is set so that timer0 ticks every 64 clock cycles, and the // the overflow handler is called every 256 ticks. //#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 256)) // the whole number of milliseconds per timer0 overflow //#define MILLIS_INC (MICROSECONDS_PER_TIMER0_OVERFLOW / 1000) // the fractional number of milliseconds per timer0 overflow. we shift right // by three to fit these numbers into a byte. (for the clock speeds we care // about - 8 and 16 MHz - this doesn't lose precision.) //#define FRACT_INC ((MICROSECONDS_PER_TIMER0_OVERFLOW % 1000) >> 3) //#define FRACT_MAX (1000 >> 3) //timer0 overflow interrupt ISR(TIMER0_OVF

Questions about programming?Chat with your personal AI assistant