Re: 溫度sensor 程式原理
|
||||
---|---|---|---|---|
新會員
|
謝謝~我懂了
發表於: 2008/11/13 16:38
|
|||
|
溫度sensor 程式原理
|
||||
---|---|---|---|---|
新會員
|
usbCDC範例程式有溫度sensor 程式轉換ASCLL的程式
void UpdateCelsiusASCII(void) { WORD temp; byte i; temp._word = temperature._word >> 3; if(temp.HighB.b4 == 0) { temp.HighB._byte &= 0b00011111; tempString[0] = '+'; } else { temp.HighB._byte |= 0b11100000; tempString[0] = '-'; temp._word = temp._word ^ 0xFFFF; // Negate temp._word++; }//end if temp._word = (temp._word*10U) >> 4; // Turn into celsius xx.x /* Populate string */ for(i=4;i>0;i--) { tempString[i] = (((char)(temp._word % 10)) & 0x0F) | 0x30; temp._word /= 10; }//end for /* Turn leading zeros into spaces */ if(tempString[1] == '0') { tempString[1] = ' '; if(tempString[2] == '0') tempString[2] = ' '; }//end if /* Adjust decimal digit */ tempString[5] = tempString[4]; tempString[4]='.'; tempString[6]=0x00 ; // Null-Terminated }//end UpdateCelsiusASCII ================================== 其中temp._word = (temp._word*10U) >> 4;這行是幹麻呢? for(i=4;i>0;i--) { tempString[i] = (((char)(temp._word % 10)) & 0x0F) | 0x30; temp._word /= 10; }//end for 這for迴圈又做了什麼事 這兩個地方我看了很久不知道是怎麼轉換的有誰知道呢?我有看了TC77的data,0.0625度c為000FH
發表於: 2008/11/13 13:22
|
|||
|