📄 app.c
字号:
#include "avr/io.h"
/* FCPU : 1Mhz
* CPU : ATMega16 */
void TimerConfig(void)
{
/* WGM[1;0]=[1,1] : Fast PWM
* COM[1;0]=[1,1] : Set OC0 on compare match, clear OC0 at BOTTOM
* CS0[2:0]=[1,0,1] : Clock=FCPU/1024 (From prescaler) */
TCCR0=(1<<WGM00)|(1<<WGM01)|(1<<COM01)|(1<<COM00)|(1<<CS02)|(0<<CS01)|(1<<CS00);
/* Set the value of Timer/Counter Register to 0 */
TCNT0= 0x00;
/* Set the value of Output Compare Register to half of the top(255) value */
OCR0 = 127;
}
int main(void)
{
/* Set LED and Seg LE pin as output , databus as output */
DDRA |=(1<<PA4)|(1<<PA5)|(1<<PA6);
DDRB = 0xFF;
/* Off the Seg display */
PORTB = 0x00;
PORTA|= (1<<PA4)|(1<<PA5);
PORTA&=~((1<<PA6)|(1<<PA5));
/* Off the led and enable the Led LE */
PORTB = 0xFF;
PORTA|= (1<<PA6);
TimerConfig();
while(1)
{
;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -