mega8.c
来自「AVR 初学者」· C语言 代码 · 共 43 行
C
43 行
//ICC-AVR application builder : 2008-8-1 19:01:17
// Target : M8
// Crystal: 16.000Mhz
#include <iom8v.h>
#include <macros.h>
void port_init(void)
{
PORTB = 0x00;
DDRB = 0x00;
PORTC = 0x00; //m103 output only
DDRC = 0x7F;
PORTD = 0x00;
DDRD = 0x00;
}
//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
MCUCR = 0x00;
GICR = 0x00;
TIMSK = 0x00; //timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
void main()
{
unsigned int i,j,K;
init_devices();
PORTC = 0X2A;
while(1)
{
for(i=0;i<500;i++)
for(j=0;j<300;j++);
PORTC = ~PORTC;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?