当前位置:首页 > 红外体温计的设计 - 图文
江苏理工学院毕业设计说明书(论文)
if(TX_byte(SlaveAddress)){ //Send SlaveAddress-------------------??? }
DataL=RX_byte(ACK);
//Read low data,master must send
goto
repeat; //Repeat comunication again
ACK
DataH=RX_byte(ACK); Pec=RX_byte(NACK);
//Read high data,master must send ACK
//Read PEC byte, master must send
NACK
STOP_bit();
arr[5]=SlaveAddress; arr[4]=command;
//
//
//Stop condition
arr[3]=SlaveAddress; arr[2]=DataL; arr[1]=DataH; arr[0]=0;
//Load array arr
// // //
PecReg=PEC_calculation(arr);//Calculate CRC
//If received and calculated CRC are equal go
}while(PecReg != Pec);
out from do-while{} }
unsigned char PEC_calculation(unsigned char pec[])
第 25 页 共 61 页
*((unsigned char *)(&tdata))=DataH; //
*((unsigned char *)(&tdata)+1)=DataL; //data=DataH:DataL
return tdata;
江苏理工学院毕业设计说明书(论文)
{
do{
crc[5]=0; crc[4]=0; crc[3]=0; crc[2]=0; crc[1]=0x01; crc[0]=0x07; BitPosition=47; shift=0;
/* Set maximum bit position at 47 */
/* Load CRC value 0x000000000107 */
unsigned char crc[6]; unsigned char unsigned char unsigned char unsigned char unsigned char
BitPosition=47; shift; i; j; temp;
//Find first 1 in the transmited message i=5; j=0;
while((pec[i]&(0x80>>j))==0 && i>0){
BitPosition--; if(j<7){ } else{ }
第 26 页 共 61 页
j=0x00; i--; j++;
/* Set highest index */
江苏理工学院毕业设计说明书(论文)
}/*End of while */
shift=BitPosition-8; /*Get shift value for crc value*/
//Shift crc value while(shift){
for(i=5; i<0xFF; i--){
if((crc[i-1]&0x80) && (i>0)){ } else{ }
crc[i]<<=1; crc[i]+=temp;
temp=0; temp=1;
}/*End of for*/ shift--;
}/*End of while*/
//Exclusive OR between pec and crc for(i=0; i<=5; i++){
pec[i] ^=crc[i];
}/*End of for*/
}while(BitPosition>8);/*End of do-while*/
return pec[0];
}/*End of PEC_calculation*/
第 27 页 共 61 页
江苏理工学院毕业设计说明书(论文)
4.2显示模块设计
4.2.1显示模块分析
本次设计采用的是LCD5110液晶显示屏进行数值的显示,单片机将接收到的数字信号进行内部处理之后送至LCD5110进行数值显示。LCD5110驱动指令如表4-1所示:
表4-1驱动指令
4.2.2软件程序:
图4-4软件程序流程图。
第 28 页 共 61 页
共分享92篇相关文档