TLC2543驱动程序
来源:互联网 发布:mysql 查询重复记录 编辑:程序博客网 时间:2024/05/22 12:05
/mcu51 发表于2007-06-17, 22:09
/**************************************
TLC2543驱动程序
*************************************/
#include <reg51.h>
#include <intrins.h>
/**************************************
2543控制引脚宏定义
*************************************/
#define CLOCK p17 /*2543时钟*/
#define D_IN p16 /*2543输入*/
#define D_OUT p14 /*2543输出*/
#define _CS p15 /*2543片选*/
#define uint unsigned int
#define uchar unsigned char
/**************************************
名称:delay
功能:延时模块
输入参数:n要延时的周期数
输出参数:无
*************************************/
void delay(uchar n)
{
uchar i;
for(i=0;i<n;i++)
{
_nop_();
}
}
/**************************************
名称:read2543
功能:TLC2543驱动模块
输入参数:port通道号
输出参数:ad转换值
*************************************/
uint read2543(uchar port)
{
uint ad=0,i;
CLOCK=0;
_CS=0;
port<<=4;
for(i=0;i<12;i++)
{
if(D_OUT) ad|=0x01;
D_IN=(bit)(port&0x80);
CLOCK=1;
delay(3);
CLOCK=0;
delay(3);
port<<=1;
ad<<=1;
}
_CS=1;
ad>>=1;
return(ad);
}
/**************************************
名称:main
功能:主函数
输入参数:无
输出参数:无
*************************************/
void main()
{uint ad;
while(1)
{
ad=read2543(0);
}
}
TLC2543驱动程序
*************************************/
#include <reg51.h>
#include <intrins.h>
/**************************************
2543控制引脚宏定义
*************************************/
#define CLOCK p17 /*2543时钟*/
#define D_IN p16 /*2543输入*/
#define D_OUT p14 /*2543输出*/
#define _CS p15 /*2543片选*/
#define uint unsigned int
#define uchar unsigned char
/**************************************
名称:delay
功能:延时模块
输入参数:n要延时的周期数
输出参数:无
*************************************/
void delay(uchar n)
{
uchar i;
for(i=0;i<n;i++)
{
_nop_();
}
}
/**************************************
名称:read2543
功能:TLC2543驱动模块
输入参数:port通道号
输出参数:ad转换值
*************************************/
uint read2543(uchar port)
{
uint ad=0,i;
CLOCK=0;
_CS=0;
port<<=4;
for(i=0;i<12;i++)
{
if(D_OUT) ad|=0x01;
D_IN=(bit)(port&0x80);
CLOCK=1;
delay(3);
CLOCK=0;
delay(3);
port<<=1;
ad<<=1;
}
_CS=1;
ad>>=1;
return(ad);
}
/**************************************
名称:main
功能:主函数
输入参数:无
输出参数:无
*************************************/
void main()
{uint ad;
while(1)
{
ad=read2543(0);
}
}
- TLC2543驱动程序
- [转帖]TLC2543驱动程序
- 基于STM32的TLC2543驱动程序
- LCD1602 + TLC2543
- TLC2543驱动2
- TLC2543芯片AD转换例子
- 单片机AD转换程序 TLC2543
- TLC2543和TLV5614的STM32程序
- TLC2543和mini2440通信的速率
- 驱动程序
- 驱动程序
- 驱动程序
- 驱动程序
- 驱动程序
- 驱动程序
- 驱动程序
- 基于GCCAVR的TLC2543读写程序----模拟SPI方式实现
- 求解tlc2543数据采集为什么用于显示1602没有反应
- 谈软件测试用例的可重用性
- 全国出国培训备选人员外语考试BFT成绩可以免考职称英语。QQ:1002756451 电话020-88535077
- SWT对话框自动关闭
- GridView多表头类
- Oracle 常用SQL查询列表
- TLC2543驱动程序
- 项目管理师_备考3
- 向C#的String类添加按字节截取字符串的扩展方法
- C#日期格式化
- wxString与std::string之间的转换
- 从终端输入一组数据进行进栈、出栈操作并将其结果打印出来(采用顺序栈的方式)
- Convert 与转化时间有关的实例
- 网络字节序与主机字节序
- 冒泡排序法