⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tlc0838.c

📁 8位ADC TLC0838 的C语言程序
💻 C
字号:
#include <reg52.h>
#define HIGH=1;
#define LOW=0;
extern void write_portA(unsigned char);
extern void my_delay(unsigned char );

sbit DIO=P3^1;
sbit SE=P3^0;

unsigned char read_0838(unsigned char chanel_num,unsigned char low_three)
{
	unsigned char i;
	unsigned char j;
	i=5;
        low_three=7-low_three;
        if ((chanel_num & 0x01)!=0)
           chanel_num=chanel_num+0x08;

	chanel_num=chanel_num+0x30;	//起始
	chanel_num=chanel_num<<2;
	write_portA(low_three);		//clk=0,cs=0
	SE=0;
send_lp:
	if ((0x80 & chanel_num)!=0)
		DIO=1;
	else
		DIO=0;
	my_delay(5);
	write_portA(0x08+low_three);	//clk=1,cs=0
	my_delay(5);
	write_portA(low_three);		//clk=0,cs=0
	chanel_num=chanel_num<<1;
	i=i-1;
	if (i>0)
		goto send_lp;
	//下面是一个空周期
	my_delay(5);
	write_portA(0x08+low_three);	//clk=1,cs=0
	//上面是一个空周期
	j=0;
	i=8;
read_lp:
	my_delay(5);
	write_portA(low_three);	//clk=0,cs=0
	my_delay(5);
	write_portA(0x08+low_three);	//clk=1,cs=0
	j=j<<1;
	if (DIO==1)
        	j=j+1;
	i=i-1;
	if (i>0)
		goto read_lp;
	my_delay(5);
	write_portA(0x10+low_three);	//cs=1
	return(j);
}

⌨️ 快捷键说明

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