资源描述:
《msp430流水灯蜂鸣器实验报告》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、MSP430实验报告水位报警器姓名:丁宇昊学号:021210508otherstaffoftheCentre.Duringthewar,ZhuwastransferredbacktoJiangxi,andDirectorofthenewOfficeinJingdezhen,JiangxiCommitteeSecretary.Startingin1939servedasrecorderoftheWestNorthOrganization,SecretaryoftheSpecialCommitteeAfte
2、rthevictoryofthelongMarch,hehasbeentheNorthwestOfficeoftheFederationofStateenterprisesMinister,ShenmufuguSARmissions,DirectorofNingxiaCountypartyCommitteeSecretaryandrecorderoftheCountypartyCommitteeSecretary,Ministersand一、实验目的:掌握msp430单片机的程序编写和运行过程。掌握IA
3、REmbeddedWorkbench程序的编译和运行。二、实验内容:用继电器代替传感器输入模拟电压,用IED灯显示水位高度,当超过预定值时,蜂鸣器响,实现报警。三、使用串口:P1口,P2口四、电路实现:把继电器作为的AD的输入,通过AD转换,把电压分成16小分,每一份信号控制1个led,通过改变led两端电平高低,控制led亮灭。当到达预定值时,把蜂鸣器的接口设置为高电平。五、实验代码:#includevoiddelay(intj){doj--;while(j!=0);}intmai
4、n(void){otherstaffoftheCentre.Duringthewar,ZhuwastransferredbacktoJiangxi,andDirectorofthenewOfficeinJingdezhen,JiangxiCommitteeSecretary.Startingin1939servedasrecorderoftheWestNorthOrganization,SecretaryoftheSpecialCommitteeAfterthevictoryofthelongMarch
5、,hehasbeentheNorthwestOfficeoftheFederationofStateenterprisesMinister,ShenmufuguSARmissions,DirectorofNingxiaCountypartyCommitteeSecretaryandrecorderoftheCountypartyCommitteeSecretary,MinistersandWDTCTL=WDTPW+WDTHOLD;//StopWDTADC10CTL0=ADC10SHT_2+ADC10ON
6、+ADC10IE;//ADC10ON,interruptenabledADC10CTL1=INCH_1+SREF0;//inputA1ADC10AE0
7、=BIT7;//PA.1ADCoptionselectP1DIR
8、=BIT0;//SetP1.0tooutputdirectionP1DIR
9、=BIT4;P1DIR
10、=BIT5;P2DIR
11、=0xff;P2OUT
12、=0xff;P2SEL&=0x00;for(;;){ADC10CTL0
13、=ENC+ADC10SC;//Samplingandconversio
14、nstart__bis_SR_register(CPUOFF+GIE);//LPM0,ADC10_ISRwillforceexitif(ADC10MEM>960){P1OUT
15、=BIT4;P1OUT&=~BIT5;P2OUT=0xFE;}elseif(ADC10MEM>900){P1OUT
16、=BIT4;P1OUT&=~BIT5;P2OUT=0xfc;}elseif(ADC10MEM>840){P1OUT
17、=BIT4;P1OUT&=~BIT5;P2OUT=0xf8;}elseif(ADC10MEM>780
18、){P1OUT
19、=BIT4;P1OUT&=~BIT5;P2OUT=0xf0;}elseif(ADC10MEM>660){P1OUT
20、=BIT4;P1OUT&=~BIT5;P2OUT=0xe0;}elseif(ADC10MEM>600){P1OUT
21、=BIT4;P1OUT&=~BIT5;otherstaffoftheCentre.Duringthewar,ZhuwastransferredbacktoJiangxi,andDirectorof