#include
#include"temp.h"
typedef unsigned int u16;
typedef unsigned char u8;
char num=0;
u8 DisplayData[8];
u8 smgduan[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void delay(u16 i)
{
while(i--);
}
void datapros(int temp)
{
float tp;
if(temp< 0)
{
DisplayData[0] = 0x40;
temp=temp-1;
temp=~temp;
tp=temp;
temp=tp*0.0625*100+0.5;
}
else
{
DisplayData[0] = 0x00;
tp=temp;
}
DisplayData[1] = smgduan[temp / 10000];
DisplayData[2] = smgduan[temp % 10000 / 1000];
DisplayData[3] = smgduan[temp % 1000 / 100] | 0x80;
DisplayData[4] = smgduan[temp % 100 / 10];
DisplayData[5] = smgduan[temp % 10];
}
/*void DigDisplay()
{
u8 i;
for(i=0;i<6;i++)
{
switch(i)
{
case(0):
LSA=0;LSB=0;LSC=0; break;
case(1):
LSA=1;LSB=0;LSC=0; break;
case(2):
LSA=0;LSB=1;LSC=0; break;
case(3):
LSA=1;LSB=1;LSC=0; break;
case(4):
LSA=0;LSB=0;LSC=1; break;
case(5):
LSA=1;LSB=0;LSC=1; break;
}
P0=DisplayData[5-i];
delay(100);
P0=0x00;
}
}*/
void main()
{
WDTCTL = WDTPW + WDTHOLD;
P1SEL |= 0x40;
UCB0CTL1 |= UCSWRST; // Enable SW reset
UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC; // I2C Master, synchronous mode
UCB0CTL1 = UCSSEL_2 + UCSWRST; // Use SMCLK
UCB0BR0 = 12; // fSCL = SMCLK/12 = ~100kHz
UCB0BR1 = 0;
UCB0I2CSA = 0x48; // Slave Address is 048h
UCB0CTL1 &= ~UCSWRST;
while(1)
{
datapros(Ds18b20ReadTemp());
DigDisplay();
}
}
错误提示:
error #10234-D: unresolved symbols remain
error #10010: errors encountered during linking; "DS18B20.out" not built
gmake[1]: *** [DS18B20.out] Error 1
makefile:139: recipe for target 'all' failed
gmake: *** [all] Error 2