文档库 最新最全的文档下载
当前位置:文档库 › max6675测温程序

max6675测温程序

max6675使用简单,是3位串行通信
sbit SO = P1. 1 ;
sbit CS = P1. 2 ;
sbit SCK= P1. 3 ;
unsigned char resulth ,resultl ;
unsigned char flag;
void read(void)
{
unsigned char i ;
resulth = resultl = 0 ;
SCK= 0 ;
CS = 0 ;
SCK= 1 ;
SCK= 0 ; / / 输出数据D15
SCK= 1
for (i = 4 ;i > = 1 ;i - - ) / / 读取转换结果的高四位
{ SCK= 0 ;
resulth^0 = SO; / / 读取SO 输出的字节
resulth = resulth < < 1 ; / / 数据左移
SCK= 1 ;
}
for (i = 8 ;i > = 1 ;i - - ) / / 读取转换结果的低8 位
{
SCK= 0 ;
resultl^0 = SO;
resultl = resultl < < 1 ;
SCK= 1 ;
}
SCK= 0 ;
flag = SO; / / 读取断偶标志
SCK= 1 ;
SCK= 0 ; / / 输出数据D0

相关文档