10位数模转换器TLC5615程序
#include <ioavr.h>#include <avr_macros.h>
#include <MCU_C_Macro_Data_Define.h>
#include "void_main.h"
// AVR驱动程序:
//接口定义
#defineDA_0 CLR_BIT(PORTF,PF5)
#defineDA_1 SET_BIT(PORTF,PF5)
#defineCK_0 CLR_BIT(PORTF,PF6)
#defineCK_1 SET_BIT(PORTF,PF6)
#defineCS_0 CLR_BIT(PORTF,PF7)
#defineCS_1 SET_BIT(PORTF,PF7)
//数据写入
void da5615(unsigned int da)
{
unsigned char i;
da <<= 6;//10有效数据左对齐
CS_0;
CK_0;
for (i=0;i<12;i++)
{
if(da &0x8000)
DA_1;
else
DA_0;
CK_1;
da <<= 1;
CK_0;
}
CS_1;
CK_0;
} 自己顶一下 呵呵呵呵顶了啊 好好,简洁 顶顶! 记号 看看… 讲讲10位有效数据……为什么要左移六位 回复【7楼】yuan90826
-----------------------------------------------------------------------
If the daisy chain (cascading) function (see daisy-chaining devices section) is not used, a 12-bit input data
sequence with the MSB first can be used
高位优先 mark 谢谢你的点拨,我这个程序搞了一天了,哎,相见恨晚! 学习中, 标记,51上面已经用了.效果很好
页:
[1]