msp430单片机程序(LT-1B_Programs).docx

上传人:李司机 文档编号:7184225 上传时间:2024-06-29 格式:DOCX 页数:119 大小:314.87KB
返回 下载 相关 举报
msp430单片机程序(LT-1B_Programs).docx_第1页
第1页 / 共119页
msp430单片机程序(LT-1B_Programs).docx_第2页
第2页 / 共119页
msp430单片机程序(LT-1B_Programs).docx_第3页
第3页 / 共119页
msp430单片机程序(LT-1B_Programs).docx_第4页
第4页 / 共119页
msp430单片机程序(LT-1B_Programs).docx_第5页
第5页 / 共119页
点击查看更多>>
资源描述

《msp430单片机程序(LT-1B_Programs).docx》由会员分享,可在线阅读,更多相关《msp430单片机程序(LT-1B_Programs).docx(119页珍藏版)》请在三一办公上搜索。

1、一、基础试验【10个】1、入门试验:1.ED闪耀(1个)2、时钟试验:设置MC1.K、AC1.K.SMC1.K(1个)3、低功耗试脸:设置低功耗模式(1个)4、IQ端口试验:IO端口寄存器设置(1个)5、定时器:看门狗定时器、TinierA寄存器设置(2个)6、比较器:比较器A寄存器(1个)7、Flash:flash读写(1个)8、异步通信:异步通信寄存器设置(1个)9、ADC:ADCI2寄存器设置(I个)二、开发板模块简洁程序【56个】1、1.ED流水灯试验(红、黄、绿)(1) 1.ED1:检测开发板(2) 1.ED2:般I。限制闪耀(3) 1.ED3:PWM信号限制闪耀2、蜂鸣器试验(I)

2、婵鸣器I:单频音(步进变音调)(2)蜂鸣器2:奏乐(祝你平安)3、数码管试验(I)数码管I(显示123456)(2)数码管2(动态显示O-F)(3)数网管3(流消光圈)(4)数码管4(米回光标)4、4x1独立按键试验(1) 4X1键盘I:(2) 4X1健盘2:(3) 4X1键盘3:(4) 4X1键盘4:扫描数码管显示中断数码管显示限制1.ED限制蜂鸣器5、4x4矩阵键盘试验(1)4X4键盘I:行列扫描数码管显示(2) 4X4键盘2:行列扫描1602液晶髭示(3) 4X4健盘3:限制1.ED蜂鸣器6、1602液晶试验(1) 1602液晶I:动态字符显示(2) 1602液晶2:静态字符显示(3)

3、1602液晶3:内部时钟显示(4) .3V-5V电平转换试验(1)电平转换I:输出5V方波(2)电平转换2:输出不同占空比的方波(3)电平转换3:MC1.K.SMC1.K.AC1.K8、RS232接口试验(1) RS232接口1:MCU发送数据Pe机显示(2) RS232接口2:按键限制MCU发送数据PC机尾示(3)RS232接口3:PC机发送数据MCU液晶显示(4) RS232接口4:MCU回发接收到的PC机数据(5) RS232接口5:RS232限制蜂鸣9、RS485接口试脸(1) RS485接口】:发送程序(2) RS485接U2:接收程序10、USB接口试验(1) USB接口1:简洁连

4、接测试(2) USB接1.l2:USB接收数据(3) USB接口3:USB发送数据IkPS2接口试验(I)PS2接UhPS2限制1602显示(2) PS2接口2:PS2限制数码管显示(3)PS2接口3:PS2E艮制1.ED和蜂鸣器12、12-Bit高精度温度传感器试验(I)温度传:感器I:DS18B2O在数码管显示(2)温度传感器2:DSI8B2O在液晶显示13、RTC实时时钟试验(1)实时时钟I:DS1302测试(2)实时时钟2:DS13O2电子钟14、2kBitEEPROM试验(1) EEPROMI:AT24C02测试(2) EEPR0M2:读出数据通过串口在PC机显示15、12-Bit模

5、数转换器(ADC)接口试验(I)模数转换器I:ADC在数码管显示(2)模数转换器2:ADC在1602液晶在显示(3)模数转换器3:ADC通过串U在PC机显示16、8-Bi1数模转换器(DAe)试验(I)数模转换器I:DAC限制1.ED(2)数模转换器2:DAC输出电压,ADC采样转换并在液晶上显示17、12864液晶试验(与12864液晶配套)(1) 12864液晶井口I:字符显示(2) 1283液晶并口2:汉字显示(3) 12864液晶井口3:图形显示(4) 12864液晶井口4:综合演示(5) 12864液晶串口5:字符显示(6) 12864液晶串口6:汉字显示(7) 12864液晶巾口7

6、:图形品示(8) 12864液晶串口8:综合演示18、射频模块CC100o试验(9) 射频模块1:发送数据(2)射频模块2:接收数据19、UCoS移植注:17、18程序随模块赠送三、开发板综合程序301、键盘综合试验(10) 4X4健盘+好呜器+1.ED+数码管显示(11) 4X4键盘+蜂呜器+1.ED+1602液晶显示(12) 4*4键盘+蛭呜器+1口+?(?机技示(13) PS2键盘+UART+PC机显示(14) PS2键盘+USB+PC机显示2、接口综合试验(I)Usbouart(2)Uartousb(3) RS2320RS485(4) RS485DRS2323、温度时间综合试验(1)

7、DS18B2O+DS13O2+数码管(2) DS18B2O+DS13O2+USB(3) DSI8B2O+DSI3O2+UART(4) DS18B2O+DS13O2+16024、ADDA综合试验(1) ADC+1602(2) ADC+UART(3) ADC+USB(4) DAC+1.ED+KEY(5) DAC+VART(6) DAC+USB(7) AlX:+UART+DS1302(8) ADC+DAC+!6O2+KEY(9) ADC+DAC+UARTKEY5、其他综合试验(1)AT24CO2高级应用(搜寻,擦除.读出全部(2) DS1302高级应用(内部RAM存取数据6、12864液晶综合试验(

8、1)汉字库(2)图形库7、3.2寸TFr触摸屏试验(1)静态图片(2)动画程序功能:BrdConfg.h头文件8*8*4*才4*8*8本8*84*4*4*号*号*号*号4冷号冷8*8*E*分/Iypcdcfunsignedcharuchar;Iypcdefunsigncdimuim;“限制位的宏定义#dcfincCtr1.OutP3D1R=B3+BIT6+BI7;#dcfincCtrl_O#defineSRC1.K,l*defineSRC1.KJ)#dcfincSER#dCfinCSERJ)#defineRC1.K_I他fineRC1.K.0P30UT&=-(B1T3BIT6BIT7)P3OU

9、T=B1T7P3OUT&=B1T7P30UT=B1T6P3OIT=-BIT6P3OUT=B3P3OUT&=BIT3板上资源配置函数voidBoardConfig(ucharcnd)(uchari;Ctr1.Out;Ctr1.O:fbr(i=0;i#includcBrdConfig.h,uinli=OJ=OJir=0:uintflag=O.spccd=0:flag一灯光流淌方式.印CCd灯光流淌速度/余京衾:衾*:*:*:*!分*拿主困数*:*:*拿*/void11ain(void)WDTCT1.=WDTPW+WDTHO1.D;关闭看门狗BoardCtMifig(OxfO):CCT1.O=CCI

10、E;使能CCRo中断CCRO=50000;TACT1.=TASSE1._2+ID_3+MC:定时器A的时钟源选择SMC1.K.增计数模式P2DIR=Oxff:设置P211方向为输出P2OUT=OxfT;-E1NT();使能全局中断1.PMO;“CPU进入1.PMo模式函数名称:Timer,A功能:定时涔A的中断服务函数,在这里通过标记限制流水灯的流淌方向和流淌速度参数:无返回值:无*/*p11gnavector=TIMERAO_VECTOR_interruptvoidTimCJA(void)Iiftflag=0)(P2OUT=(0x8(i+);/灯的点亮依次D8-D1elseif(flag=I

11、)(P2OI=(0x()l(i+):/灯的点亮依次D1-D8else(if(dir)/灯的点亮依次D8-D1.DI-D8.循环绕固P2OUT=(0x80Xi+);elseP2OUT=0x0l(i+);Iif(i=8)i=0:dir=-dir;j+:ftj=40)Ii=0;j=0:flag+:if(flag=4)flag=0;Switch(Speed)IcaseO:TACT1.=-(IX)IDI);TACT1.I=ID_3;break;case 1:TACT1.=-(IX)IDI);TACT1.I=ID_2;break:case 2:TACT1.=-(I0IDI);TACT1.I=ID_1;br

12、eak;case 3:TACT1.&=-(ID0+ID1);TACT1.I=ID_0;break;default:break;ifflag!=3)speed+;if(speed=4)speed=0;)程序功能:用从P2.3和P2.4蚪出的PWM波形驱动1.EDMP2.3口输出方波的占空比为75%P2.4I给出方波的占空比为25%测试说明:视察1.ED的亮灭的时间长短挈*8*4零*4一4*8*8*g*S4*冷4*8*号*号*甘44*44*y*8*y*4*44c*/#include#includcRoardConfig.h”voidnuin(void)WDTCTI.=WDTPWWDTHOI.D;B

13、ixadConfig(OxbO);P2DIR=Oxff:P2OUT=Oxff:P2SE1.=B113BIT4;CCRO=4096I:CCT1.l=O1.TMOD.7:CCRI=3072;CCT1.2=OUTMOD.7;CCR2=1024;TACT1.=TASSE1._1+ID_3+MC-1;_BIS_SR(1.PM3_bits);n关狗/关闭数码管和电平转换,打开流水灯P2端口设置为输出/关闭其他1.ED/P2.3和P2.4连接内部模块PWM周期为IS/CCRlreset7set/CCRlPWMdutycycle/CCR2rcsctsc/CCR2PWMdutycycIe/AC1.K8,upmo

14、de/Enter1.PM3“今*衾*衾*衾*衾*衾*今*分*宓*a*分*衾*分*衾*今*a*衾*衾MSP-FET430P140DCmO-BasicClock.OutputBufferedSMC1.K.AC1.KandMC1.KHDescription:OutputbufferedMCI.K.SMC1.KandAC1.K./C1.K=1.FXTI=32768.MC1.K=DCOMax.SMC1.K=XT2HXTAUSREQUIRED-NOTINSTA1.1.EDONFET/MinVccrequiredvarieswithMC1.Kfrequency-refertodatasheet*/IlHMS

15、P430FI49/剂X1N-HIl132kIl-IRSTXOUTI-/IIIX,2IN-HIXTA1.(455k-8Mhz)HIRSTXT2OUT.nIIHIP5.4-MC1.K=DCOMaxIP5.5-SMC1.K=XT2IP5.6-AC1.K=32kHz/M.Buccini/Texaslns(mnwntsInc.HFeb25/BuiltwithIAREmbeddedWorkbenchVersion:3.2IA#in#includcBoardConfighvoidnain(void)(BoardConflg(OxbS);HStopWatchdogTimer/MaxDCO/XT2on.maRS

16、E1./SMC1.K=XT2/P5.6,5.4OiiipmsP5.6.5.5optionsWDTCT1.二WDTPWVDTHO1.D;DCOCT1.=DCOO+DCOl+DCO2;BCSC1.1=RSE1.O+RSE1.l+RSE1.2;BCSCTI.2=SE1.S;P5D1R=0x70:P5SE1.=0x70;whilc(I)()/MSP4ET430PI40DcmoBasicClock.1.PMJUsingWDTISR.32kHzAC1.KHHDescription:ThisprogramOperaIeSMSP430normallyin1.PM3pulsingP3.4Hat4secondin

17、tervals.WDTISRusedIowake-upsystem.AllVOconfigured/asIOWtwtputstoeliminateIloatinginputs.CurrentconsumptiondocsHincreasewhen1.EDispoweredonP3.4.DcmoformeasuringI.PM3current.C1.K=1.FXTI/4=32768/4,MC1.K=SMC1.K=defaultDCO,产ExternalWiHChcrystalonXINXOUTisrequiredforAC1.K*/H/MSP430F149/MX1N-HIl132kHzH-IRS

18、TXOUT-IIHIP3.5-1.EDItHDashcngH1.ilianElectronicInc.BFCb2008BuiltwithIAREmbeddedWorkbenchVersion:3.42A分*衾*食*京*京冬*:衾*a*衾*今*京*拿*衾*1:*今*衾*分*f;*a*衾*衾*分*京*京冬*:衾*a#include#includcRoardConfig.h”voidmain(void)BixdConfig(0xb8);BCSCT1.1|=DIVA_2:WDC1.=WDT_AD1.Y_I(XM):IEli=WDTIE;PIDIR=OxFF:PIoUT=0:P2DIR=OxFF;P2O

19、UT=0;P3DIR=OxFF:P3=0x30;P4DIR=OXFF;P4OUT=0;P5DIR=OxFF:P5OUT=0:P6DIR=OXFF;P6OUT=0x80;/AC1.K/4WDTId4inten,altimerEnableWDTintcnupt/Al)P1.xoutputs/AllPl.xreset/AllP2.xoutputsAllP2.xreset/AllP3.xoutputs/AllP3.xreset/AllP4.xoutputs/AllP4,xreset/Al)P5.xoutpuls/AllP5.xreset/AllP6.xoutputs/llP6,xtsewhilc(1)

20、Iuinti;_BIS_SR(1.PM3_bitsGIE):P3OUT=-BIT5;for(i=18()0();i0;i);P3OUT=BIT5;/Enter1.PM3/SctP3.51.EDon/Delay/ClearP3.51.EDoff#PnIgmavec(or=VDT_VECTOR_interruptvoidWaIChdOg_Jimer(void)I/Clear1.PM3bitsfrom(XSR)_BIC_SR_IRQ1.EDDashcng1.ilianElectronicInc.Rb2008BuiltwithIAREmbeddedWorkbenchVersion:3.42A#incl

21、ude#includcBoardConfigjrvoidmain(s,oid)BoardConfig(OxbX):WDTCTI.=WDTPWWDTHOI.D;P3DIR=BIT4;StopwacchdogtimerHSetP3.4tooutputdirectionvolatileunsignedinti:P3OUT=BIT4:/rIbgglcP3.4usingcxclusivc-ORi=5000();do(i-);while(i!=0):Delay今*衾*衾*:拿*/*今京衾*:今*今*4:*|:*今*衾*食*案*案衾*衾*:衾*分*拿*京*衾*衾*分*/*今木衾*才MSP-FET430PI4

22、0DVmo-WDT.ToggleP3.4.InlervalOverflowISR.DCOSMC1.KDescription:ToggleP3.4usingsoftwaretimedbyIhcWDTISR.Togglerateisaroximatcly3()msbasedondcfauh-SoOkhzDCoSMC1.KdocksourceusedinIhisexamplefortheWDT.AC1.K=n/a.MC1.K=SMC1.K=defaultDCO-8(X)kMSP430F149Il-IRSTXOUTkIP3.4-1.ED/IfDashcng“1.i,11anElectronicInc.

23、IlFeb2()08BuihwithIREmbeddedWorkbenchVersion:3.42A48*8*8*号号4*4*3*8*8*号*斗444*号*号4444*笈*8*8*号*号4*号*号*8*844*4*4*号*8#includcincludeBrdConfig.h,void11uin(void)(BoardConfig(C)XbD;WDTCT1.=WDT.MD1.Y.32;IEI=WDTIE:P3DIR=BIT4;_BIS_SR(1.PMO,bitsGIE);关闭数码管、流水灯和电平转换SeiWatchdogTimerintervalto-*30msEnabkWDTinle11pl

24、/SetP3.4tooutputdirectionEnter1.PMOw/in(erruM/WatchdogTinwrinterruptserviceroutine#Pragmavecior=WDT_VECTOR_intcr11p1.ED/Dashcng1.iTIanElectronicInc./Feb28HBuiltwithIAREmbeddedWorkbenchVenion:3.42A/include#iiKlude.BoanlConfighvoidmain(void)(WDl250ms.AC1.K.intervaltimerEnableWDTinterrupt/SetP3.4tooutp

25、utdirectionEnter1.PM3w/interrupt/ToggleP3.4usingexclusive-ORBtKirdConfig(Oxb8):WDCI,1.=WDIAD1.Y_250;IEI=VDTIE;P3DIR=BIT4;BlS.SR(1.PM3.bils+GlE);HWalchdogTimerinterruptSerViCeNHllinC#pragmavcctor=WDT-VECiR_interruptvoidwacchdog_timcrtvoid)IP3OUT=BIT4:48*8*8*号44*4*甘*8*8*号*4-444*号*号*号:1.ED/HDashcngH1.i

26、TianElectronicInc./Rb2008BuiltwithIAREmbeddedWorkbenchVersion:3.42A#includc#includcBrdConfig.h,voidIiuiin(Void)IWDTCTI.二WDTPWWDTHOI.D;BiXirdConfig(OxbS);P3DIR=BIT4;CCT1.O=CCIE:CCRO=50000;TACT1.=TSSE1.2Mj2:/StHTimerAOinterruptserviceriHitine#pragmavcctor=TIMERA(1.VECTOR_interruptvoidTimCjA(void)IP3OU

27、T=BIT4:CCRO+=5(XKM):/MSPFET43OPI40Dcmo-TimCjA,ToggleP3.4,CCROUpModeISR.DCOSMCi.K/Descriplion:ToggleP3.4usingsoftwareandTA_0ISR.ThnCJAisconfiguredforupmode,thusthetimerovcrilowswhenIARcountstoCCRO.Inthisexample,CCROisloadedwith20000.C1.K=a,MC1.K=SMC1.K=TAC1.K=defaultDCO-SOOkHz/HMSP430F149IlMX1N-HIlI/

28、-RSTXOUT-II/IP3.4-1.ED/DashcngIJTianElectronicInc.Feb2008/BuihwithIAREmbeddedWorkbenchVersion:3.42AQindIKk#includc,BoardConfigJimvoidmain(void)IWDTCT1.=WDTPW+WDTHO1.D:BoardConfig(0xbX);P3DIR=B4;CCT1.O=CCIE;CCRO=20000:TAeT1.=TASSE1._2+MCJ_BIS_SR(1.PMO_bits*GIE);)/StopWDT/P3.4outputUCCROi11(emtenabled

29、SMC1.K.upnuxlcHEnter1.PMOw/interrupt/TimerAOinterruptserviceroutine#PlNgmavecior=TlMERAO_VECTOR_inlcrrup(P3OUT=BIT4;/ToggleP3.4HMSPFET430PI40DemO-TiinejA,ToggleP3.4.OverflowISR.DCOSMC1.K/Description:ToggleP3.4usingsoftwareandTimejAOvCrnoW1SR.InthisexampleanISRtriggerswhenTAovert!ows.InsidetheTAHover

30、flowISRP3.4istoggled.Togglerateisappcoxima(Iely12Hz.IfProperuseoftheTAIVinlermpnstrated.BAC1.K=n,a.MC1.K=SMC1.K=TAC1.K=defaultDCo800kHzHIlMSP430FI49/HMXIN-HIlITRSTXOUT-II/IP3.4-1.EDHHDasheng/1.ilianEleclronicInc.HFCb2008/BuihwithIAREmbeddedWorkbenchVersion:3.42A含*分*:分*衾*京*今*衾*衾*衾*:*/*!;*衾*今*拿*京*今*:分

31、*衾*衾今I;*衾*衾*分*a*/*京*今*衾*衾*/include/includeBoitrxJConfig.h,voidnuin(void)WDTCTI.=WDTPWWDTHOI.D;BoafdConfig(OxbS):P3DIR=BIT4;AC1.=TASSE1._2+MC_2+TAlE:_BIS_SR(1.PMO_bits+GIE);/StopWDT/P3.4output/SMC1.K.CCntmOde.interruptUEnter1.PMOw/interruptTimcr_A3InterruptVector(TA!V)handler#PlNgmavecixTIMERA1.VECTO

32、R_intcrrupvoidTiJner_A(VUid)switch(TA!V)easeeaseease2:break:4:break:1():P30UT=BIT4;break:/CCRlIKHusedCCR2nousedHovcrowMSP-FE430P14()Dcmo-Timer,A.ToggleP3.4.Overflow!SR.32kHzAC1.KDescription:ToggleP3.4usingSofIWareand(beTilnejAoveflowISR.InthisexampleanISRtriggerswhenTAoverflows.InsidetheISRP3.4ktogg

33、led.Togglerateisexactly0.5Hz.PrOPeruseoftheTAIVinterruptvectorgeneratoris1.EDDashcng1.ilianElectronicInc./Feb2(X)8/BuiltwithIAREmbeddedWorkbenchVersion:3.42A“分*:衾*衾*衾*t;*京*分*分*今*衾*衾*衾*冬*京*会*衾*:今*衾*:*今*:衾*分*京*1:*京*衾*衾*#includc#includcBgrdConAghvoidIiuiin(Void)IWDTCTI.:WDTPWWDTHOI.D;BxdConfig(0xb8);P3

34、DIR=BIT4;TAeT1.=TASSE1._1+MC_2+TAlE;_BIS_SR(1.PM3_bits*GIE);)Timcr_A3InterruptVector(TAlV)handler*pragmaVecior=TIMERAI.VECTOR_inlcrrupvoidTimeJA(VUid)(switch(TAIV)case2:break:ease4:break:ease10:P3OUT=BIT4;break;)SIoPWDTUP3.4outputAC1.K.contmodc.interruptUEnter1.PM3w/interrupt/CCRlnotused/CCR2notused/overflow#iiwludcincludeBoardConfigNvoid11ain(void)(WDTCT1.=VDTHO1.DWDTPW;H关看门狗BoQrdC

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号