2012年TI杯msp430单片机电压值幅度值菜单显示程序

上传人:野鹰 文档编号:1271048 上传时间:2017-06-04 格式:TXT 页数:11 大小:13.54KB
返回 下载 相关 举报
2012年TI杯msp430单片机电压值幅度值菜单显示程序_第1页
第1页 / 共11页
2012年TI杯msp430单片机电压值幅度值菜单显示程序_第2页
第2页 / 共11页
2012年TI杯msp430单片机电压值幅度值菜单显示程序_第3页
第3页 / 共11页
2012年TI杯msp430单片机电压值幅度值菜单显示程序_第4页
第4页 / 共11页
2012年TI杯msp430单片机电压值幅度值菜单显示程序_第5页
第5页 / 共11页
点击查看更多>>
资源描述

《2012年TI杯msp430单片机电压值幅度值菜单显示程序》由会员分享,可在线阅读,更多相关《2012年TI杯msp430单片机电压值幅度值菜单显示程序(11页珍藏版)》请在金锄头文库上搜索。

1、我以前倒是做过,不过程序还有点问题,调时间的时候容易过界,但正常走时候就正常了。开发环境用的IAR,单片机用f149,显示用的1602的四线模式。你自己看着改程序吧,其实我也是51上移植过去的。悲剧了,帖不下了.我帖在我博客里了啊,自己去找吧.主程序_分隔线_#include #include ds1302.h#include LCD1602x4_mps.h#define DS1302_SECOND 0x81 /时钟芯片的寄存器位置,存放时间#define DS1302_MINUTE 0x83#define DS1302_HOUR 0x85#define DS1302_WEEK 0x8b#de

2、fine DS1302_DAY 0x87#define DS1302_MONTH 0x89#define DS1302_YEAR 0x8d unsigned char DateString11,TimeString9,week_value2,TempBuffer7; /char hide_sec,hide_min,hide_hour,hide_day,hide_week,hide_month,hide_year;char done,count,temp,flag,up_flag,down_flag;/unsigned int temp_value=0,temp_max=0;temp_min=0

3、; /温度值void DateToStr(void) /将时间年,月,日,星期数据转换成液晶显示字符串,放到数组里DateString unsigned char Year,Month,Day,Week;Year=rtc_getyear();Month=rtc_getmon();Day=rtc_getdate();Week=rtc_getday();if(hide_year2就不显示,输出字符串为 2007/07/22 DateString0 = 2;DateString1 = 0; DateString2 = Year/10 + 0;DateString3 = Year%10 + 0;els

4、e DateString0 = ;DateString1 = ; DateString2 = ;DateString3 = ;DateString4 = /;if(hide_month0x59) / 过59 , temp=0; break;case 2:temp=dataread(DS1302_MINUTE); / 分数temp=temp+1; /分数加1up_flag=1;if(temp0x59) / 过59分, temp=0;break;case 3:temp=dataread(DS1302_HOUR); / 时数temp=temp+1; / 时数加1up_flag=1;if(temp0x

5、23) / 过23 时, temp=0;break;case 4:temp=dataread(DS1302_WEEK); / 星期数temp=temp+1; /星期数加1up_flag=1;if(temp0x7) temp=1;break;case 5:temp=dataread(DS1302_DAY); / 日数temp=temp+1; /日数加1up_flag=1;if(temp0x31)temp=1;break;case 6:temp=dataread(DS1302_MONTH); / 月数temp=temp+1; /月数加1up_flag=1;if(temp0x12)temp=1;br

6、eak;case 7:temp=dataread(DS1302_YEAR); / 年数temp=temp+1; /年数加1up_flag=1;if(temp0x99)temp=0;break;default:break; while(!(P1IN&BIT1);delay_nms(2); /void Downkey()/ 序 if(!(P1IN&BIT2)switch(count)case 1:temp=dataread(DS1302_SECOND); / 数temp=temp-1; / 数 1down_flag=1; /数据调 后 if(temp&0x7f)0x59) / 0 , 59 tem

7、p=0x59;break;case 2:temp=dataread(DS1302_MINUTE); / 分数temp=temp-1; /分数 1down_flag=1;if(temp0x59)temp=0x59; / 0 , 59 break;case 3:temp=dataread(DS1302_HOUR); / 时数temp=temp-1; / 时数 1down_flag=1;if(temp=0x00)temp=0x23;break;case 4:temp=dataread(DS1302_WEEK); / 星期数temp=temp-1; /星期数 1down_flag=1;if(temp=

8、0x00)temp=0x07;break;case 5:temp=dataread(DS1302_DAY); / 日数temp=temp-1; /日数 1down_flag=1;if(temp=0x00)temp=0x31;break;case 6:temp=dataread(DS1302_MONTH); / 月数temp=temp-1; /月数 1down_flag=1;if(temp=0x00)temp=0x12; break;case 7:temp=dataread(DS1302_YEAR); / 年数temp=temp-1; /年数 1down_flag=1;if(temp0x99)t

9、emp=0x99;break;default:break;while(!(P1IN&BIT2);delay_nms(2); void Setkey()/模式 if(!(P1IN&BIT3)count=count+1; /Setkey 一,count就加1done=1; / 调 模式while(!(P1IN&BIT3);delay_nms(2); void keydone()/ currency1 unsigned char Second;if(flag=0) /“时钟, 时 datawrite(0x8e,0x00); / temp=dataread(DS1302_SECOND);datawri

10、te(0x80,temp|0x80);datawrite(0x8e,0x80); / flag=1;Setkey(); /fi模式fl换 switch(count)case 1:do /count=2,调 outkey(); /fi 出 Upkey(); /fi加 Downkey(); /fi if(up_flag=1|down_flag=1) /数据 , 的数据datawrite(0x8e,0x00); / datawrite(0x80,temp|0x80); / 的 数datawrite(0x8e,0x80); / up_flag=0;down_flag=0; hide_sec+; /位闪

11、数if(hide_sec3)hide_sec=0;show_time(); /液晶显示数据while(count=2);break; case 2:do /count=3,调 分hide_sec=0;outkey();Upkey();Downkey();if(temp0x60)temp=0;if(up_flag=1|down_flag=1)datawrite(0x8e,0x00); / datawrite(0x82,temp); / 的分数datawrite(0x8e,0x80); / up_flag=0;down_flag=0;hide_min+;if(hide_min3)hide_min=

12、0;show_time();while(count=3);break;case 3:do /count=4,调 时hide_min=0; outkey();Upkey();Downkey();if(up_flag=1|down_flag=1)datawrite(0x8e,0x00); / datawrite(0x84,temp); / 的 时数datawrite(0x8e,0x80); / up_flag=0;down_flag=0;hide_hour+;if(hide_hour3)hide_hour=0;show_time();while(count=4);break;case 4:do /

13、count=5,调 星期hide_hour=0; outkey();Upkey();Downkey(); if(up_flag=1|down_flag=1)datawrite(0x8e,0x00); / datawrite(0x8a,temp); / 的星期数datawrite(0x8e,0x80); / up_flag=0;down_flag=0;hide_week+;if(hide_week3)hide_week=0;show_time();while(count=5);break;case 5:do /count=6,调 日hide_week=0; outkey();Upkey();Downkey();if(up_flag=1|down_flag=1)datawrite(0x8e,0x00); / datawrite(0x86,temp); / 的日数datawrite(0x8e,0x80); / up_flag=0;down_flag=0;hide_day+;if(hide_day3)hide_day=0;show_time();while(count=6);break;case 6:do /count=7,调 月hide_day=0; outkey();Upkey();Downkey();if(up_flag=1|dow

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 研究报告 > 综合/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号