完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
基础程序如下,不奢求能帮忙写出来,想问一下我应该再加什么东西。
#include #define RSPIN (0x04) //P11.2 #define RWPIN (0x02) //P11.1 #define EPIN (0x01) //P11.0 unsigned char XPOS,YPOS; //char a[]=" "; char a1[]=" : : "; char a2[]=" : : // "; int i=0,j=0; void delay(unsigned int t) { unsigned int i,j; for(i=0;i } void lcdwaitidle(void) { P10DIR=0x00; P11OUT &=~RSPIN; P11OUT |=RWPIN; P11OUT |=EPIN; while((P10IN&0x80)==0x80); P11OUT &=~EPIN; P10DIR |=0Xff; } void lcdwcn(unsigned char c) { P11OUT &=~RSPIN; P11OUT &=~RWPIN; P10OUT=c; P11OUT |=EPIN; _NOP(); P11OUT &=~EPIN; } void lcdwc(unsigned char c) { lcdwaitidle(); lcdwcn(c); } void lcdwd(unsigned char d) { lcdwaitidle(); P11OUT |=RSPIN; P11OUT &=~RWPIN; P10OUT=d; P11OUT |=EPIN; _NOP(); P11OUT &=~EPIN; } void lcdpos(void) { XPOS&=0x0f; YPOS&=0x03; if(YPOS==0x00) lcdwc(XPOS|0x80); else if(YPOS==0x01) lcdwc((XPOS+0x40)|0x80); } void lcdreset() { __delay_cycles(150); lcdwcn(0x38); __delay_cycles(50); lcdwcn(0x38); __delay_cycles(50); lcdwcn(0x38); lcdwc(0x38); lcdwc(0x08); lcdwc(0x01); lcdwc(0x06); lcdwc(0x0c); } void lcdfill(unsigned char n) { for(YPOS=0;YPOS<2;YPOS++) for(XPOS=0;XPOS<16;XPOS++){ lcdpos(); lcdwd(n); __delay_cycles(40000); } } void lcdwda(unsigned char x,unsigned char y,unsigned char *s) { YPOS=y; for(XPOS=x;XPOS<16;XPOS++) { lcdpos(); lcdwd(*s); s++; __delay_cycles(40000); } } int main(void) { WDTCTL =WDTPW+WDTHOLD; //Stop watchdog timer P7SEL|=0x03; //xt1 //loop until 32khz crystal stabilizes // P2DIR &= ~0x1f; // Set P1.0 to output direction P2REN |= 0x1f; P2OUT |= 0x1f; P2IE |= 0x1f; P2IES |= 0x1f; P2IFG &= ~0x1f; // P9DIR |= BIT6+BIT7; P9DS |= BIT6+BIT7; P9OUT &= ~BIT7; P9OUT |= BIT6; P10OUT =0; P11OUT =0; P10DIR |=0XFF; P11DIR |=0XFF; P11OUT &=~EPIN; lcdreset(); while((SFRIFG1 & OFIFG)) //test oscillator fault flag { UCSCTL7 &=~(XT2OFFG+XT1LFOFFG+DCOFFG); SFRIFG1 &= ~OFIFG; } //clear fault flags RTCCTL01=RTCBCD+RTCHOLD+RTCMODE+RTCTEVIE+RTCAIE; //RTC enable ,bcd mode //alARM every minute //enable rtc interrupt //init time RTCSEC=0x00; //Set seconds RTCMIN=0x32; //Set minutes RTCHOUR=0x10; //Set hours //inint date RTCDOW=0x03; //Set dow RTCDAY=0x30; //Set day RTCMON=0x04; //Set month RTCYEAR=0X2010; //Set year RTCCTL01 &= ~RTCHOLD; //ENABLE RTC P5DIR|=BIT5; //set p5.5 to output direction //enter LMP3 w/ interrupt __bis_SR_register(GIE); while(1) { lcdwda(0,0,a); lcdwda(0,1,a1); a[0]=((RTCYEAR>>12)&0x0F)+'0'; a[1]='0'+((RTCYEAR>>8)&0x0F); a[2]=((RTCYEAR>>4)&0x0F)+'0'; a[3]=(RTCYEAR&0x0F)+'0'; a[5]='0'+((RTCMON>>4)&0x0F); a[6]='0'+(RTCMON&0x0f); a[8]='0'+((RTCDAY>>4)&0x0F); a[9]='0'+(RTCDAY&0x0f); a1[0]='0'+((RTCHOUR>>4)&0x0f); a1[1]='0'+(RTCHOUR&0x0f); a1[3]='0'+((RTCMIN>>4)&0x0f); a1[4]='0'+(RTCMIN&0x0f); a1[6]='0'+((RTCSEC>>4)&0x0f); a1[7]='0'+(RTCSEC&0x0F); } //basic timer interrupt service routine #pragma vector=RTC_VECTOR __interrupt void RTC(void) { P5OUT ^=0x20; //toggle P5.5 using XOR RTCCTL01&=~RTCTEVIFG; } |
|
相关推荐 |
|
只有小组成员才能发言,加入小组>>
3033个成员聚集在这个小组
加入小组2928 浏览 1 评论
MSP430FR5994 使用库函数 定时器触发AD问题请教
3601 浏览 2 评论
请问怎么把下面51单片机的代码改成msp430 g2 pocket的代码,还有改下时间变成30秒
2341 浏览 1 评论
4804 浏览 1 评论
2573 浏览 1 评论
1328浏览 3评论
MSP430FR5994 使用库函数 定时器触发AD问题请教
3601浏览 2评论
2928浏览 1评论
1510浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-30 08:00 , Processed in 1.143370 second(s), Total 44, Slave 34 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号