msp430.rar

  • PUDN用户
    了解作者
  • Visual C++
    开发工具
  • 18KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 1
    下载次数
  • 2014-10-22 07:08
    上传日期
利用MSP430对带有液晶显示的进行键盘扫描
msp430.rar
  • 新建文件夹
  • key源.txt
    52KB
  • keyscan.c
    52.5KB
  • key716.txt
    52.5KB
内容介绍
#include<msp430f5418a.h> #include "1621.h" #include "mainfi.h" #define uchar unsigned char #define uint unsigned int #define keyin (P1IN & 0x0f) //ht1621Tab1用于清屏 uint Ht1621Tab1[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //ht1621Tab2用于功能显示F1-F15,流速,流量,压强 uint Ht1621Tab2[] = {0x6f,0x06,0xcb,0x8f,0xa6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //ht1621Tab3用于显示累计流量 uint Ht1621Tab3[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //Ht1621Tab31用于显示MAX uint Ht1621Tab31[] = {0x20}; //Ht1621Tab32用于清除MAX,MIN uint Ht1621Tab32[] = {0x00}; //Ht1621Tab41用于显示MIN uint Ht1621Tab41[] = {0x10}; //液晶段码,用于显示F1-F15,流速,流量,压强 uint scandata[] = {0x6f,0x06,0xcb,0x8f,0xa6,0xad,0xed,0x07,0xef,0xaf,0xe7,0xec,0x69,0xce,0xe9,0xe1,0xe2,0xe3,0x6e,0x68,0xc4,0x08,0x61}; // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 // a b c d e f r p u L n _ t //液晶段码,用于显示累计流量 uint scandata2[] = {0xf6,0x60,0xbc,0xf8,0x6a,0xda,0xde,0x70,0xfe,0xfa,0x7e,0xce,0x96,0xec,0x9e,0x1e}; //n1-n15用于F1-F15显示初值,如n1为F1 DF,n2为F2000,n3为F3 PUL,....... uint n1[5]={0xe1,0x06,0x00,0xce,0xe1},n2[5]={0xe1,0xcb,0x6f,0x6f,0x6f},n3[5]={0xe1,0x8f,0xe3,0x6e,0x68},n4[5]={0xe1,0xa6,0x00,0x06,0x6f},n5[5]={0xe1,0xad,0xc4,0x6f,0xe3},n6[5]={0xe1,0xed,0x6f,0x6f,0x6f},n7[5]={0xe1,0x07,0x6f,0x6f,0x6f},n8[5]={0xe1,0xef,0x6f,0x6f,0x6f},n9[5]={0xe1,0xaf,0x00,0x00,0x06}; uint n10[5]={0xe1,0x06,0x6f,0x6f,0xe1},n11[5]={0xe1,0x06,0x06,0x00,0x8f},n12[5]={0xe1,0x06,0xcb,0xaf,0xe7},n13[5]={0xe1,0x06,0x8f,0xe7,0x06},n14[5]={0xe1,0x06,0xa6,0xe1,0x68},n15[5]={0xe1,0x06,0xad,0x6f,0x6f}; int ff=0,f3f=0,f4f=0,f5f=0,f10f=0,f11f=0,f12f=0,f13f=0,f14f=0; //保存显示的位置,如fround=1,ff=0显示n1q[0],ff=1显示n1q[1] //n1,n2用于F1,F2的功能调节实现,n1a为显示F1 DRF,n1b为F1,n2a为F2 00,n2b为F20 0,n2c为F200 ,n2a、n2b、n2c分别用来使第三、四、五位闪烁 //n2am、n2bm、n2cm用来保存第三、四、五位数据,n2m用于显示调节后的F2000,n2mm用于保存n2m,n2a1、n2b2、n2c3分别用来保存n2am、n2bm、n2cm的值 uint n1a[5]={0xe1,0x06,0xce,0xe2,0xe1},n1b[5]={0xe1,0x06,0x00,0x00,0x00},n2a[5]={0xe1,0xcb,0x00,0x6f,0x6f},n2b[5]={0xe1,0xcb,0x6f,0x00,0x6f},n2c[5]={0xe1,0xcb,0x6f,0x6f,0x00}; uint n2am[5]={0xe1,0xcb,0,0,0},n2bm[5]={0xe1,0xcb,0,0,0},n2cm[5]={0xe1,0xcb,0,0,0},n2m[5]={0xe1,0xcb,0x6f,0x6f,0x6f},n2mm[5]={0xe1,0xcb,0x6f,0x6f,0x6f},n2mms[5]={0xe1,0xcb,0,0,0}; uint n2a1[5]={0xe1,0xcb,0x00,0x6f,0x6f},n2b2[5]={0xe1,0xcb,0x6f,0x00,0x6f},n2c3[5]={0xe1,0xcb,0x6f,0x6f,0x00},n2cn=0; uint upf=0,up3f=0,up4f=0,up5f=0,up9f=0,up10f=0,up11f=0,up12f=0,up13f=0,up14f=0; //保存ff,f3f,f4f......的值 uint *n1q[2]={n1,n1a},*n2q[4]={n2,n2a,n2b,n2c},n2i=1,n2cc=1,*nxp=n1,*nxb=n1b; //设置指针变量用于显示,n2cc用于保存n2i uint n6a[5]={0xe1,0xed,0x00,0x6f,0x6f},n6b[5]={0xe1,0xed,0x6f,0x00,0x6f},n6c[5]={0xe1,0xed,0x6f,0x6f,0x00},n6am[5]={0xe1,0xed,0,0,0},n6bm[5]={0xe1,0xed,0,0,0},n6cm[5]={0xe1,0xed,0,0,0},n6m[5]={0xe1,0xed,0x6f,0x6f,0x6f}; uint *n6q[5]={n6,n6a,n6b,n6c},n6i=1,n6cc=1,n6mm[5]={0xe1,0xed,0x6f,0x6f,0x6f},n6mms[5]={0xe1,0xed,0,0,0},n6a1[5]={0xe1,0xed,0x00,0x6f,0x6f},n6b2[5]={0xe1,0xed,0x6f,0x00,0x6f},n6c3[5]={0xe1,0xed,0x6f,0x6f,0x00},n6cn=0; uint n7a[5]={0xe1,0x07,0x00,0xaf,0xaf},n7b[5]={0xe1,0x07,0xaf,0x00,0xaf},n7c[5]={0xe1,0x07,0xaf,0xaf,0x00},n7am[5]={0xe1,0x07,9,0,0},n7bm[5]={0xe1,0x07,0,9,0},n7cm[5]={0xe1,0x07,0,0,9},n7m[5]={0xe1,0x07,0xaf,0xaf,0xaf}; uint *n7q[5]={n7,n7a,n7b,n7c},n7i=1,n7cc=1,n7mm[5]={0xe1,0x07,0x6f,0x6f,0x6f},n7mms[5]={0xe1,0x07,0,0,0},n7a1[5]={0xe1,0x07,0x00,0x6f,0x6f},n7b2[5]={0xe1,0x07,0x6f,0x00,0x6f},n7c3[5]={0xe1,0x07,0x6f,0x6f,0x00},n7cn=0; uint n8a[5]={0xe1,0xef,0x00,0x6f,0x6f},n8b[5]={0xe1,0xef,0x6f,0x00,0x6f},n8c[5]={0xe1,0xef,0x6f,0x6f,0x00},n8am[5]={0xe1,0xef,0,0,0},n8bm[5]={0xe1,0xef,0,0,0},n8cm[5]={0xe1,0xef,0,0,0},n8m[5]={0xe1,0xef,0x6f,0x6f,0x6f}; uint *n8q[5]={n8,n8a,n8b,n8c},n8i=1,n8cc=1,n8mm[5]={0xe1,0xef,0x6f,0x6f,0x6f},n8mms[5]={0xe1,0xef,0,0,0},n8a1[5]={0xe1,0xef,0x00,0x6f,0x6f},n8b2[5]={0xe1,0xef,0x6f,0x00,0x6f},n8c3[5]={0xe1,0xef,0x6f,0x6f,0x00},n8cn=0; uint n15a[5]={0xe1,0x06,0xad,0x00,0x6f},n15b[5]={0xe1,0x06,0xad,0x6f,0x00},n15am[5]={0xe1,0x06,0xad,0,0},n15bm[5]={0xe1,0x06,0xad,0,0},n15m[5]={0xe1,0x06,0xad,0x6f,0x6f},n15mm[5]={0xe1,0x06,0xad,0x6f,0x6f},n15mms[5]={0xe1,0x06,0xad,0,0},n15a1[5]={0xe1,0x06,0xad,0x00,0x6f},n15b2[5]={0xe1,0x06,0xad,0x6f,0x00},n15cn=0; uint *n15q[4]={n15,n15a,n15b},n15i=1,n15cc=1; uint n3a[5]={0xe1,0x8f,0x00,0xe7,0x68},n3b[5]={0xe1,0x8f,0x69,0x6f,0xce},n3d[5]={0xe1,0x8f,0x00,0x00,0x00},*n3f[3]={n3,n3a,n3b}; uint n4a[5]={0xe1,0xa6,0x06,0x6f,0x6f},n4b[5]={0xe1,0xa6,0xad,0x6f,0x6f},n4d[5]={0xe1,0xa6,0x00,0x00,0x00},*n4f[3]={n4,n4a,n4b}; uint n5a[5]={0xe1,0xad,0xc4,0x69,0x68},n5d[5]={0xe1,0xad,0x00,0x00,0x00},*n5f[2]={n5,n5a}; uint n9a[5]={0xe1,0xaf,0x00,0x00,0xcb},n9b[5]={0xe1,0xaf,0x00,0x00,0xa6},n9c[5]={0xe1,0xaf,0x00,0x00,0xef},n9d[5]={0xe1,0xaf,0x00,0x06,0xed},n9e[5]={0xe1,0xaf,0x00,0x00,0x00},*n9f[5]={n9,n9a,n9b,n9c,n9d}; uint n10a[5]={0xe1,0x06,0x6f,0x6f,0xc4},n10d[5]={0xe1,0x06,0x6f,0x00,0x00},*n10f[2]={n10,n10a}; uint n11a[5]={0xe1,0x06,0x06,0xed,0x6f},n11b[5]={0xe1,0x06,0x06,0x08,0x08},n11d[5]={0xe1,0x06,0x06,0x00,0x00},*n11f[3]={n11,n11a,n11b}; uint n12a[5]={0xe1,0x06,0xcb,0xad,0xe9},n12d[5]={0xe1,0x06,0xcb,0x00,0x00},*n12f[2]={n12,n12a}; uint n13a[5]={0xe1,0x06,0x8f,0x68,0xe3},n13b[5]={0xe1,0x06,0x8f,0x06,0xad},n13d[5]={0xe1,0x06,0x8f,0x00,0x00},*n13f[3]={n13,n13a,n13b}; uint n14a[5]={0xe1,0x06,0xa6,0xe3,0xe2},n14b[5]={0xe1,0x06,0xa6,0x61,0xe9},n14d[5]={0xe1,0x06,0xa6,0x00,0x00},*n14f[3]={n14,n14a,n14b}; uint m[5],n[4]={0,0,0,0};//m[5]用于保存流速等数据,n[4]用于保存累计流量 uint n9val[5]={1,2,4,8,16},f9f=0; //n9val为平均移动次数 uint speed=0,temp=24,pa=10; //流量,温度,压强变量 uint circle[3]={0,0,0}; //保存流量,温度,压强 int pround=0,fround=1; //pround用来选择流量还是温度压强,fround用来显示是第几功能 uint maindi = 0,subdi = 3,*pp=Ht1621Tab2; uchar KeyVal = 0,cntt=1,flag1=0,flag3=0,flag2=0,flag4=0,dsst=2,dssum=7; // 按键的键值 uchar flag_test,flag_testtime=0; uchar tems; uint *q[16]={m,n1,n2m,n3,n4,n5,n6m,n7m,n8m,n9,n10,n11,n12,n13,n14,n15m}; //切换功能数组 //用于消抖的延时 void delay(void) { uint tmp; for(tmp = 12000;tmp > 0;tmp--); } //延时用于闪烁 void delay1(void) { uint tmp; for(tmp = 40000;tmp > 0;tmp--); } //延时用于闪烁 void delay2(void) { uint tmp2; for(tmp2 = 40000;tmp2 > 0;tmp2--); } //按键检测及处理程序 void keyscan(void) { int i,j; if(keyin != 0x0f) //如果有键被按下 { delay(); //延时消抖 if(keyin != 0x0f) //再次检测按键状态 { tems=keyin; j=0; while(keyin != 0x0f) //等待按键被放开 {for(i=0;i<30000;i++);//70ms j++;} if((j>3)&&(tems==0x0d))//判断是否中键长按3秒 进入测试状态 {KeyVal = 5; flag_testtime=0; if(flag_test==0&&flag_testtime==0){flag_test=1;flag_testtime=1;} if(flag_test==1&&flag_testtime==0){flag_test=0;flag_testtime=1;} } if(j<=3) switch(tems) //转换键值 { case 0x0e: //1键按下 KeyVal = 1; dsst=2;dssum=5; //定义显示总数及起始地址 if(flag3 == 0) //中键没有按下或者第二次按下 { pround++; //变量加1,流量、温度、压强切换
评论
    相关推荐
    • msp430.rar
      msp 430 中文使用手册 和 c 注释
    • MSP430 LPM
      这里是MSP430 2系列 MCU LPM 模式设置的原代码,希望对大家有用.
    • MSP430代码
      基于MSP430定时器如何实现DAC的转化,用的是C语言编程风格!
    • msp430资料
      单片机msp430的资料,大家参考下 单片机msp430的资料,大家参考下 单片机msp430的资料,大家参考下
    • msp430程序
      十天学会msp430单片机所有程序(包含第3部分),还有TI例程。很好的模块参考。
    • MSP430相关例程
      适合MSP430初学者,有各种相关例程,便于快速上手
    • MSP430课件
      MSP430相关课件,包括单片机的概述、单片机的结构、时钟与低功耗等
    • MSP430测频
      实现MSP430单片机测频,单片机需超频至12M主频,采用最常用的低频测周,高频计数方法,频率测量范围达到0.1Hz-20MHz,理论上还可以测更高频率,但是手头只有20M的信号发生器
    • MSP 430 完整例程
      msp430x21x2_1.c Software Toggle P1.0 msp430x21x2_1_vlo.c Software Toggle P1.0, MCLK = VLO/8 msp430x21x2_lpm3.c Basic Clock, LPM3 Using WDT ISR, 32kHz ACLK msp430x21x2_lpm3_vlo.c Basic Clock, LPM3 ...
    • MSP430学习笔记
      MSP430学习笔记系列,是电赛培训的资料之一。 文件列表: │ MSP430学习笔记系列3—MSP430中断、内嵌函数、时钟系统.pdf │ MSP430学习笔记系列4—MSP430定时器.pdf │ MSP430学习笔记系列5—USCI模块(串口-SPI-I...