热度 4
2012-7-1 19:03
672 次阅读|
0 个评论
时钟总是受温度影响,SD2068 可以通过调整的时钟走时 来调整精度。 温度采集用的是热敏电阻,价格低,但是有1%的误差。 //****************************************************************** if (sec 600) // 每10分钟根据温度校准精度 { sec = 0; y = AD_Tempreture(); //采集热敏电阻阻值 i= rtTable ; //把热敏电阻阻值变换成温度值 ,16进制显示。 x = ((i0xf0)4)*10+ (i0x0f); //16进制变换成10进制 if (y 0xbd) i = TTFTable ; //0xbd 0点 else i = TTZTable ; SetTimeAdject(i); } /********** 调整时间误差 *********************/ void SetTimeAdject(unsigned char dat) { WriteTimeOn(); I2CStart(); I2CSendByte(Sd2068_W_Addr); I2CWaitAck(); I2CSendByte(0x12); //设置写起始地址 I2CWaitAck(); I2CSendByte(dat); //清零数字调整寄存器 I2CWaitAck(); I2CStop(); WriteTimeOff(); } const rom unsigned char rtTable = { 0x7a,0x7a,0x7b,0x7c,0x7c,0x7c,0x7d,0x7d,0x7d,0x7e, //0~9 0x7e,0x7e,0x7f,0x7f,0x7f,0x7f,0, 0, 0, 0, //10~19 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //20~29 0x00,0x7f,0x7f,0x7f,0x7f,0x7e,0x7e,0x7e,0x7e,0x7d, //30~39 0x7d,0x7d,0x7c,0x7c,0x7c,0x7b,0x7b,0x7a,0x79,0x79, //40~49 0x78,0x77,0x77,0x76,0x75,0x75,0x74,0x73,0x72,0x72, //50~59 0x71,0x70,0x6e,0x6e,0x6d,0x6c,0x6b,0x6a,0x69,0x68, //60~69 0x67,0x66,0x65,0x63,0x62,0x60,0x5f,0x5d,0x5c,0x5a, //70~79 0x59,0x58,0x56,0x55,0x54,0x52 }; //---------------------------------------------------------------- const rom unsigned char TTFTable = { 0x78,0x78,0x77,0x77,0x76,0x76,0x75,0x74,0x74,0x73, //-1~-10 0x72,0x72,0x71,0x70,0x6f,0x6f,0x6e,0x6d,0x6c,0x6b, //-11~-20 0x6a,0x6a,0x69,0x68,0x67,0x66,0x65,0x64,0x63,0x62, //-21~-30 0x61,0x60,0x5f,0x5e,0x5c,0x5b,0x5a,0x59,0x58,0x57 //-31~-40 };