111.c

来自「温度测量ds18b20.rar」· C语言 代码 · 共 55 行

C
55
字号
//ICC-AVR application builder : 2008/11/19 20:51:44
// Target : M8
// Crystal: 8.0000Mhz

#include <iom8v.h>
#include <macros.h>
#include "mydelay.h"
#include "ds18b20.h"

void delay1s(void)
{
 unsigned char i,j,k;
 for (i=100;i>0;i--)
  for (j=100;j>0;j--)
   for (k=20;k>0;k--)
    ;
}
void port_init(void)
{
 PORTB = 0x00;
 DDRB  = 0xff;
 PORTC = 0x00; //m103 output only
 DDRC  = 0x00;
 PORTD = 0x00;
 DDRD  = 0xff;
}

//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 data;
 unsigned char dataL,dataH;
 init_devices(); 
 while(1)
 {
   convert();
   data=rdtemp();
   dataL=data;
   dataH=data>>8;
 delay1s();
 }
}

⌨️ 快捷键说明

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