at89c51 c语言程序,At89c51 + ds1302 digital pipe c programat89c51+ds1302数码管c语言程序(国外英语资料).doc...

At89c51ds1302digitalpipecprogramat89c51ds1302数码管c语言程序(国外英语资料)

At89c51 + ds1302 digital pipe c programat89c51+ds1302数码管c语言程序(国外英语资料)

# include < reg51. H >

# include < intrins. H >

H # include < math.h >

# define uchar unsigned char

# define uint unsigned int

# define S_RST DS_RST = 1

# define C_RST DS_RST = 0

# define S_CLK DS_CLK = 1

# define C_CLK DS_CLK = 0

# define Write_Disable RW_DS1302 (0x8e, 0x80) / / write protection

# define Write_Enable RW_DS1302 (0x8e, 0x00) / / allowed to write

Sbit SET P1 = ^ 5; / / set keys

Sbit ADD = P1 ^ 4; / / adjust to add

Sbit DEC = P1 ^ 6; / / adjust the reduction

Define RdefineT1 = 0; TL1 = 0; TR1 = 0; A = 0; / / initialization timeout detection

/ / pound define Delay2us (). _nop_ (); / / delay 2us, every nop 1us

/ / pound define Delay8us (). _nop_ (); _nop_ (); _nop_ (); _nop_ (); _nop_ (); _nop_ (); _nop_ ();

# define ReDetectTime 20 / / set the number of repeated tests, over time

/ / ds18b20 command

# define SkipROM 0xCC

# define MatchROM 0x55

# define ReadROM 0x33

# define SearchROM 0xF0

Pound sign define AlarmSearch 0xEC

# define Convert 0x44 / / start temperature conversion

# define WriteScr 0x4E

# define ReadScr 0xBE

# define CopyScr 0x48

# define RecallEE 0xB8

# define ReadPower 0xB4

Pound sign define md collect_time

# define mg (collect_time [0] & 0x70) / 16

Pound sign define fd collect_time

# define fg (collect_time [1] & 0x70) / 16

# define sd collect_time

# define sg (collect_time [2] & 0x30) / 16

Sbit DS_RST = p ^ 2; / / DS reset end

Sbit DS_CLK P1 = ^ 0; / / the SCLK end

Sbit DS_IO P1 = ^ 1; / / IO port

Sbit DS18B20 P1 = ^ 3; / / temperature sensor interface

Bit the rid_device_info_keyboard, flash, STA = 1;

Uchar, choose a;

Uchar collect_time [3] = {0x45, 0x23, 0x11}; / / define variable seconds

Uchar collect_temperature [2] = {0}.

Uchar num [10] = {0x7e, 0x48, 0x3d, 0x6d, 0x4b, 0x67, 0x7f, 0x7f.

/ / seven segments of digital tube display

Uchar display [8] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x07, 0x08};

Void delay (uint I)

{

Uint k;

While (I -)

{

(k = 0; k < 120; k + +) {; }

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值