wjyspring 发表于 2007-10-20 17:12:01

请问马老师,CodeVisionAVR里的18B20温度函数怎么使用?

请问马老师,CodeVisionAVR里的18B20温度函数怎么使用?
这个程序错在哪儿了?
/************************************
程序功能:在数码管上显示检测到的温度传感器的个数
         并将温度保存在temp里
*************************************/
#include <mega128.h>
#include <delay.h>      
#asm

    .equ __w1_port=0x18 ;PORTB

    .equ __w1_bit=6    //PB6连到1820的数据线上

#endasm
#include <ds18b20.h>                        
#define MAX_DEVICES 2

unsigned char rom_codes;

flash char led_7={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,
                      0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71};
void main(void)
{
        char i = 0;   
        unsigned char devices;
         float temp;

        PORTD=0xFF;
        DDRD=0xFF;   //PD连接共阴级数码管的ABCDEFGP

         devices = w1_search(0xf0,rom_codes);

         for (i=0;i<devices;i++)
            {
               ds18b20_init(&rom_codes,25,35,DS18B20_12BIT_RES);
            };   
       
         temp=ds18b20_temperature(&rom_codes);

        while (1)
               {
       
                PORTD = led_7;
                delay_ms(1000);

               };
}

我查看了CodeVisionAVR的HELP和论坛上的很多关于18B20的帖子,还是没能搞懂,马老师您能不能耽误一下,写个
CodeVisionAVR里的18B20温度函数应用的例程?基本功能是把采集到的温度保存在变量temp里。

machao 发表于 2007-10-20 21:55:51

CVAVR的HELP中有应用例程,先学习,把它做出来。
页: [1]
查看完整版本: 请问马老师,CodeVisionAVR里的18B20温度函数怎么使用?