main._c

来自「一个关于AVR单片机的例程」· _C 代码 · 共 43 行

_C
43
字号
// ICC-AVR application builder : 2007-2-14 21:34:00
// Target : M16
// Crystal: 7.3728Mhz
// 18B20 演示程序

#include "config.h"

void port_init(void)
{
 PORTA = 0x00;
 DDRA  = 0x00;
 PORTB = 0x00;
 DDRB  = 0x00;
 PORTC = 0x00; //m103 output only
 DDRC  = 0x00;
 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(void)
{
 unsigned int temp1;
 init_devices();
 while(1)
 {
 gettemp();
 display(count,0); //补零模式显示温度
 }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?