我正在尝试使用 timer0 中断用 atmega328p 制作闪烁的 LED。
这是一个非常基本的东西,但 Microchip Studio 给了我这个:
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped=======
如何解决这个问题?代码附在下面:
#include<avr/io.h>
#include<avr/interrupt.h>
#include<util/delay.h>
#define F_CPU 1000000UL
int main(void)
{
//define inputs and outputs
DDRC = (1<<DDC4); // portc4 as output
TCNT0 = 0x00;
TCCR0A = 0x00;
TCCR0B = (1<<CS00) | (1<<CS01);
TIMSK0 = (1<<TOIE0);
sei(); // set global interrupts
while (1)
{
PORTC4 |= (1<<PORTC4);
}
}
ISR(TIMER0_OVF_vect) {
TCNT0 = 0x00;
PORTC &= ~(1<<PORTC4);
}