代码一: #include <msp430x14x.h> ; void int_clk() { BCSCTL1 &= ~XT2OFF; BCSCTL2 |= SELM_2 + SELS; do { IFG1 &= ~OFIFG; ;i<;i++) _NOP(); }); IFG1 &= ~OFIFG; } void int_COMPARATORA() { P2SEL |= BIT3 + BIT4; //P2.3,P2.4分别作为比较器的输出和输入 P2DIR |=…
代码一:Timer_A触发转换 #include <msp430x14x.h> void main() { WDTCTL = WDTPW + WDTHOLD; P6SEL |= BIT0; TACTL |= TASSEL_2 + MC_2; TACCTL1 = OUTMOD_3; TACCR1 = 0X0FFF; ADC12CTL0 = ADC12ON + SHT0_2; ADC12CTL1 = SHS_1 + SHP; ) { ADC12CTL0 |= ENC; ADC12CTL0 |= A…
注意蓝牙模块的接法! #include <msp430x14x.h> ]; ; void int_clk() { BCSCTL1 &= ~XT2OFF; BCSCTL2 |= SELM_2 + SELS; do { IFG1 &= ~OFIFG; ;i<;i++) _NOP(); }); IFG1 &= ~OFIFG; } void int_usart() { U0CTL |= SWRST; U0CTL |= CHAR; U0TCTL |= SSEL1; U0BR…
代码一: //****************************************************************************** //Description:SPI slave talks to SPI master using 3-wire mode. Data is sent //to the master starting at 0x00 and increments. Received data from the //master is expe…
代码一: #include <msp430x14x.h> void int_clk() { BCSCTL1 &= ~XT2OFF; BCSCTL2 |= SELM_2 + SELS; do { IFG1 &= ~OFIFG; ;i<;i++) _NOP(); }); IFG1 &= ~OFIFG; } void int_usart() { U0CTL |= SWRST; //复位串口 U0CTL |= CHAR; //8位数据 U0TCTL |= SSEL1; /…
代码一: /******************************* 程序功能:ACLK=32768Hz PWM波 T=512/32768 占空比75% *********************************/ #include <msp430x14x.h> void main() { WDTCTL = WDTPW + WDTHOLD; TACTL = TASSEL_1 + TACLR; CCTL0 = 0X00; CCTL1 = 0X00; CCR0 = -; //T=51…
1.捕获模式 #include <msp430x14x.h> unsigned ,last1=; unsigned ,j=; void mian(void) { WDTCTL = WDTPW + WDTHOLD; TACTL = TACLR + TASSEL_2 + ID_3 + MC_3; TACCTL0 = CM_3 + CCIS_0 + SCS + CAP + CCIE; TACCTL1 = CM_3 + CCIS_1 + SCS + CAP + CCIE; P1DIR = 0X00;…
1.看门狗产生方波 #include <msp430x14x.h> void main() { WDTCTL = WDT_MDLY_32; IE1 |= WDTIE; P1DIR |= BIT1; _EINT(); } #pragma vector=WDT_VECTOR __interrupt void Watchdog(void) { P1OUT ^= BIT1; } 2.增计数模式 #include <msp430x14x.h> void main() { WDTCTL = W…
代码一: /************************** 功能:LED每隔1秒闪烁一次 ****************************/ #include <msp430x14x.h> void main() { P6DIR = 0XFF; P6OUT = 0X00; TACCR0 = ; TACCTL0 = CCIE; TACTL = TASSEL_1 + ID_3 + MC_1; _EINT(); LPM3; } #pragma vector=TIMERA0_VECTOR…
代码 /*********************************** 程序功能:用按键控制LED状态 缺点:按键按下后无法改变LED灯的状态,可以利用板上的复位键^~^ *************************************/ #include <msp430x14x.h> ; void int_clk(); void led(int n); void main() { WDTCTL = WDTPW + WDTHOLD; int_clk(); P1DIR = 0X…