You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gg-button/other_architectures.c

34 lines
950 B

void timer_init_mega16(void)
{
ICR1 = (1 << 11) - 1;/* 11 bit pwm */
OCR1A = 0;
TCCR1A = (1 << COM1A1) | (1 << CS10) | (1 << WGM11);/* fast pwm, non inverted, top in ICR1 */
TCCR1B = (1 << WGM13) | (1 << WGM12) | (1 << CS10);/* fast pwm, top in ICR1, */
DDRD |= (1 << PD5);/* set pwm pin as output */
TIMSK = 1 << TOIE1;/* interrupt at top */
}
void timer_init_tiny45(void)
{
PLLCSR = 1 << PLLE;/* pll enable */
delay_us(100);
while(!(PLLCSR & (1 << PLOCK))) {;}/* wait for lock */
PLLCSR |= 1 << PCKE;/* use pll */
OCR1C = 0xff;
/* output pin: OC1A = PB1 = 6 */
OCR1A = 0;
TCCR1 = (1 << PWM1A) | (1 << COM1A1) | (1 << CS10);/* pwm enable, non inverted, no prescaler */
DDRB |= (1 << PB1);
/* output pin: OC1B = PB5 = 3 */
//OCR1B = 0;
//TCCR1 = (1 << CS10);/* no prescaler */
//GTCCR = (1 << PWM1B) | (1 << COM1B1);/* pwm enable, non inverted */
//DDRB |= (1 << PB5);
TIMSK = 1 << TOIE1;/* interrupt on overflow */
}