//*****************************************************************
//*名称:void ht1621_write_string(unsigned char *prt,address,len) *
//*功能:向ht1621写入一组显示数据 *
//*参数:prt 指向字节数组的指针 *
//* address 数据首地址 *
//* len 数组的长度 *
//*返回:无 *
//*****************************************************************
void ht1621_write_string(unsigned char *prt,unsigned char address,unsigned char len)
{
unsigned char temp;
HT1621_CS_CLR;
ht1621_send_bit_h(0xA0,3); //发送写数据模式101
ht1621_send_bit_h(address<<2,6); //发送地址
if((len+address)>HT1621_RAMSIZE)
{
len=HT1621_RAMSIZE-address;
}
for(temp=0;temp<len;temp++)
{
ht1621_send_bit_l(*prt++,8); //发送数据字节
}
HT1621_CS_SET;
}
//***********************************************************
//*名称:void ht1621_int() *
//*功能:ht1621初始化 *
//*参数:无 *
//*返回:无 *
//***********************************************************
void ht1621_int(void)
{
ht1621_send_cmd(HT1621_BIAS); // 设置LCD偏压发生器为1/3偏压,4个公共端
ht1621_send_cmd(HT1621_SYSTEN); // 打开系统时钟振荡器
ht1621_send_cmd(HT1621_LCDON); // 打开LCD偏压振荡器
ht1621_send_cmd(HT1621_RC256K); // 启动内部256KRC 振荡器
}
//***********************************************************************************
//*名称: delay_nus(unsigned int nms) *
//*功能: 延时nms *
//*参数: 无 *
//*返回: 无 *
//***********************************************************************************
void delay_nus(unsigned int nms)
{
while(nms--)
{
_delay_loop_2(2);
}
}
SIGNAL(TIMER1_CAPT_vect)
{
unsigned int temp;
temp=ICR1; // 获取间隙+脉冲的时间
TCNT1=0x0000;
if(temp>1024&&temp<1225) // 判断数据0信号
{
temp=0;
}
else if(temp>2145&&temp<2345) // 判断数据1信号
{
temp=0x8000;
}
else if(temp>13400&&temp<14600) // 判断引导码信号
{
bitcnt=0;
user_code=0;
operate_code=0;
return; // 返回,等待下次开始接收
}
else // 干扰信号
{
return;
}
bitcnt++;
if(bitcnt<17) //开始接收前16位
{
user_code>>=1;
user_code|=(unsigned int)temp;
本文关键字:暂无联系方式AVR单片机,单片机-工控设备 - AVR单片机