51单片机利用IIC总线对LM75A温度进行读取

#include #include "..\config\c8051f350.h"#include "..\config\const.h"#include "..\driver\system.h"#include "..\driver\other.h"#define IIC_WRITE 0#define IIC_READ 1#define VREF 24380static u
摘要由CSDN通过智能技术生成
#include <INTRINS.H>
#include "..\config\c8051f350.h"
#include "..\config\const.h"
#include "..\driver\system.h"
#include "..\driver\other.h"

#define IIC_WRITE 0
#define IIC_READ  1
#define VREF 24380

static unsigned long sysclk=24500000;

sbit SDA=P0^0;
sbit SCL=P0^1;
sbit led=P1^2; 

void Delay_us(unsigned int times){
	unsigned int i;
	for(i=0;i<times;i++){
		_nop_();
		_nop_();
		_nop_();
		_nop_();
		_nop_();
		_nop_();
		_nop_();
		}
}			           //延时us函数

void Delay_ms(unsigned int times)
{
	unsigned int i;
	for (i=0;i<times;i++)
		Delay_us(1000);
}					   //延时ms函数

void iic_start(void){
	  SDA = 1;
	  Delay_us(2);
      SCL = 1;
	  Delay_us(2);
      SDA = 0;
	  Delay_us(2);  
}					  //iic通信起始信号


void iic_stop(void){
	  SDA = 0;
	  Delay_us(2);
      SCL = 1;
	  Delay_us(2);
      SDA =1;
}				      //iic通信终止信号

void iic_ack(void)     
  • 4
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值