文章目录
- 一、部分程序
- 二、展示
- 三、全部代码下载
一、部分程序
int main(void)
{WDTCTL = WDTPW | WDTHOLD; //关闭看门狗init(); //屏幕初始化InitIIC(); //I2C初始化TMP_Init(); //tmp421初始化SetupRTC();_EINT();while (1){}
}#pragma vector=RTC_VECTOR
__interrupt void RTC_ISR(void)
{switch (__even_in_range(RTCIV, RTC_RT1PSIFG)){case RTC_NONE:break;case RTC_RTCRDYIFG:{Temp_MSB = R_I2C(0x55, 0x00); //读MSB 高八位,表达整数部分Temp_LSB = R_I2C(0x55, 0x10); //读LSB 第八位,高四位有效,表达小数部分,一格代表0.0625℃Temp_LSB = Temp_LSB >> 4; //右移四位float Temp_value = Temp_LSB * 0.0625; //小数部分处理unsigned char Temp_LSB1 = Temp_value * 100;sprintf(buf1, "%d", Temp_MSB); //类型转换sprintf(buf2, "%d", Temp_LSB1);Init_buff(); //数据显示//display("Temperature:", 20, 12, 0, 1, 0, 0);display(&buf1, 80, 84, 0, 1, 0, 0);display(".", 128, 84, 0, 1, 0, 0);display(&buf2, 144, 84, 0, 1, 0, 0);/* RTCDOW RTCMON RTCDAY RTCHOUR RTCMIN RTCSEC *///读取时间nian = RTCYEAR;yue = RTCMON;ri = RTCDAY;shi = RTCHOUR;fen = RTCMIN;miao = RTCSEC;zhou = RTCDOW;}break;case RTC_RTCTEVIFG:break;case RTC_RTCAIFG:break;case RTC_RT0PSIFG:break; /* 分频器 0 */case RTC_RT1PSIFG:break; /* 分频器 1 */default:break;}__no_operation();
}
二、展示
显示实时时间和温度。
三、全部代码下载
下载:
https://docs.qq.com/sheet/DUEdqZ2lmbmR6UVdU?tab=BB08J2
资料:
https://qq742971636.blog.csdn.net/article/details/112093263
https://qq742971636.blog.csdn.net/article/details/103341709