資源描述:
《基于msp430f5438的矩陣按鍵掃描程序》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、基于msp430f5438的矩陣按鍵掃描程序**function:matrixkeyscanprogramttinclucle〃msp430x54x./six>lxsix>lx>lx>lxsix>lxsixsixsixsixsix/X
2、SXJS#
3、SXJSxjsxpxxyxxpxxpxxpxXJSXTXXTXXTX^rxXTXXTXXTXXTXXTX?JXX
4、XZTHZTH?JX?Jxz
5、xz
6、x?Jx?Jx*macrodefinition^Jx>£^>£^>£^>£^six>lz>lx>lxsix>lx>lz>lz>lz>lx>lxsl^%
7、xsixsix
8、sixsix>lx/^gxxjxxys#
9、sxjsxy^xyxxpxxpxxrxxjxxjxxrx^Jxxjxxjxxtxxjxztxx
10、x?jxx
11、xzthzth?jx?jxz
12、xxts/#defineuintunsignedint//definitiondatatypeabbreviationttclefineucharunsignedchar#defineKEYINP4IN//defineportregisterttdefineKEYOUTP40UTttclefineKEY_DIRP4DIR#defineBO(0x01)//adefinitionttd
13、efineBl(0x02)ttclefineB2(0x04)#defineB3(0x08)ttdefineB4(0x10)ttdefineB5(0x20)ttdefineB6(0x40)ttdefineB7(0x80)*functiondeclarationUcharScan(void);//matrixkeyboardscanningVoidDelay(uintdelay_num);//delayfunctionUintTranslate(ucharcode);//scancodetranslation*globalvariabledefinitionUc
14、harkey_code;//returntothekeyboardscancodeUintkey_value;//thecorrespondingdigitalkeyboardConstuchar//key_table[17]={scandecodingtableOxFF//nokeypress//fourhighscanningline,forthelowfourcolumnscanning0x7E/0x7D/0x7B/0x77/OxBE/OxBD/OxBB/0xB7/OxDE/OxDD/OxDB/0xD7/OxEE//KI/K2/K3/K4/K5/K6/
15、K7/K8/K9/K10/K11/K12/K13OxED//K14OxEB//K150xE7//K16};/slzslzslzslzsix%lzslzslz%Iz%lz%Iz%lz%lz%lzslz%Iz%lz%lzslzslzsl^sl^slzslzslzsl^slzslz/#T^X7^XT%XTXXTXXTXXTXXTX#T^#T^^TX<1^<1^^TX^TX^TX?!%#T>#T>>T^#T^#T^>F^>F^#T^#T^>T>>T>*function(module)Name:Main()**function:callthekeyboardscann
16、er,initializetheI/Oport*callthefunctionlist:scan(),Translate()*callthisfunctionlist:None*inputparameters:None*outputparameters:None**functionreturnvalue:no*ResourcewatchdogI/Oportmoduleusedby***otherinstructions:NoneVoidmain(void)WDTCTL二WDTPW+WDTHOLD;//stopwatchdogKEY_DIR二(B7+B6+B5
17、+B4);//set10high4bitoutput,lowinputfor4KEY_OUT二0x00;//10high4bitoutputlowlevelWhile(1){Key_code二Scan();Call/returnscanner,scancodeKey_value二Translate(key_code);//callscancodetranslationfunctionreturnsthedigitalkeyboardIf(key_value!=0)//ifakey{(_N0P);//setabreakpointhere,observethes
18、cancodeanddigitalkeyboard*