msp430f449+msp430 launchpad

Download msp430f449+msp430 launchpad

Post on 08-Jan-2016

84 views

Category:

Documents

5 download

Embed Size (px)

DESCRIPTION

msp430f449+msp430 launchpad. 1 、开发环境: IAR Embedded Workbench 2 、 IAR 的安装及相应设置 3 、 IAR 的使用. msp430f449 简介. 1 、低工作电压: 1.8~3.6V 2 、超低功耗: 活动模式: 280UA ( 1MHZ , 2.2V ) 待机模式 : 1.1UA 掉电模式 : ( RAM 数据保持) 0.1UA 3 、有 5 种节电模式 4 、从待机到唤醒的响应时间不超过 6us 5 、 12 位 A/D 转换器 ( 8 通道、带有内部参考源、采样保持) - PowerPoint PPT Presentation

TRANSCRIPT

  • msp430f449+msp430 launchpad1IAR Embedded Workbench2IAR3IAR

  • msp430f44911.8~3.6V2 280UA1MHZ2.2V 1.1UA RAM0.1UA3546us512A/D 8616RISC150ns73/168UART/SPI91016011FLASH60KBRAM2KB

  • msp430f4491IO2345AD6UART7PWM8

  • 1IOP 1PxDIR / 0 1 2PxIN I/O 3PxOUT 4PxIFG 0 1 8 8 >=1.5MCLK 5PxIES 0 1 6PxSEL 0I/O 1 7PxREN / 0 1

  • P 1P1P2 2P6A/D 3P1.2P2.0PWM 4P1.1MCLK P1.5ACLK 5P2.4 P4.0TXD P2.5 P4.1RXD

  • 1PIO2P P1DIR=0xff //P1 PIOUT=0x20 // P10x20 P1DIR=0x00 //P1 data=P1IN //P1 P1DIR=BIT0; //P1.0 P1OUT|=BIT0; //P1.01 P1OUT&=~BIT0; //P1.00 P1DIR&=~BIT0 //P1.0 data=P1IN&BIT0 //P1.0

  • 2 1LFXT1CLK32768HZ 2XT2CLK8MHZ 3DCOCLK46MHZ

  • 1ACLKLFXT1CLK 2ACLK/nACLK1248 P1.53MCLK LFXT1CLKXT2CLKDCOCLK 1248 P1.1cpu4SMCLK XT2CLKDCOCLK

  • MCLK 1MCLKDCOCLK1.048576MHZ MCLK=31+1*32768 2ACLKMCLK void clk_initial() { do { IFG1&=~OFIFG; // __delay_cycles(200); } while((IFG1&OFIFG)!=0); // FLL_CTL1=SELM1+SELM0; //ACLKMCLK }

  • 3 XT2CLKMCLK void clk_initial() { do { IFG1&=~OFIFG; // __delay_cycles(200); } while((IFG1&OFIFG)!=0); // FLL_CTL1=SELM1; //XT2CLKMCLK } 4 DCOCLKMCLK121+1 *2*32768=7.995MHZ void CLK_initial() { SCFI0|=FN_4; //DCO2.8~26.6MHZ SCFQCTL=249; //DCO+ FLL_CTL0=DCOPLUS+OSCCAP_1; //DCOMCLK }

  • 31P1P22345A/D6 11P1: : P1IE|=BIT0;//P1.0

  • 0P1: : P1IE&=~BIT0;//P1.02 _EINT();//51EA=1; _DINT();//51EA=0;3Interrupt Vectors#define BASICTIMER_VECTOR (0 * 2u) /* 0xFFE0 Basic Timer */#define PORT2_VECTOR (1 * 2u) /* 0xFFE2 Port 2 */#define USART1TX_VECTOR (2 * 2u) /* 0xFFE4 USART 1 Transmit */#define USART1RX_VECTOR (3 * 2u) /* 0xFFE6 USART 1 Receive */#define PORT1_VECTOR (4 * 2u) /* 0xFFE8 Port 1 */#define TIMERA1_VECTOR (5 * 2u) /* 0xFFEA Timer A CC1-2, TA */#define TIMERA0_VECTOR (6 * 2u) /* 0xFFEC Timer A CC0 */#define ADC12_VECTOR (7 * 2u) /* 0xFFEE ADC */#define USART0TX_VECTOR (8 * 2u) /* 0xFFF0 USART 0 Transmit */#define USART0RX_VECTOR (9 * 2u) /* 0xFFF2 USART 0 Receive */#define WDT_VECTOR (10 * 2u) /* 0xFFF4 Watchdog Timer */#define COMPARATORA_VECTOR (11 * 2u) /* 0xFFF6 Comparator A */#define TIMERB1_VECTOR (12 * 2u) /* 0xFFF8 Timer B CC1-6, TB */#define TIMERB0_VECTOR (13 * 2u) /* 0xFFFA Timer B CC0 */#define NMI_VECTOR (14 * 2u) /* 0xFFFC Non-maskable */#define RESET_VECTOR (15 * 2u) /* 0xFFFE Reset [Highest Priority] */

  • 4

    PORT2_VECTOR (1 * 2u) /* 0xFFE2 Port 2 */PORT1_VECTOR (4 * 2u) /* 0xFFE8 Port 1 */TIMERA1_VECTOR (5 * 2u) /* 0xFFEA Timer A CC1-2, TA */TIMERA0_VECTOR (6 * 2u) /* 0xFFEC Timer A CC0 */ADC_VECTOR (7 * 2u) /* 0xFFEE ADC */USART0TX_VECTOR (8 * 2u) /* 0xFFF0 USART 0 Transmit */USART0RX_VECTOR (9 * 2u) /* 0xFFF2 USART 0 Receive */WDT_VECTOR (10 * 2u) /* 0xFFF4 Watchdog Timer */COMPARATORA_VECTOR (11 * 2u) /* 0xFFF6 Comparator A */TIMERB1_VECTOR (12 * 2u) /* 0xFFF8 Timer B CC1-2, TB */TIMERB0_VECTOR (13 * 2u) /* 0xFFFA Timer B CC0 */NMI_VECTOR (14 * 2u) /* 0xFFFC Non-maskae */

    RESET_VECTOR (15 * 2u) /* 0xFFFE Reset [Highest Priority] */

  • 5

    1430msp430_DINT()_EINT()23ABBABAB BCBA45,,,TA/TB/,TAIV/TBIV,; ,P1/P2,,"EINT();",, ,,.

  • 6: void interrupt_initial(){ P1DIR&=~BIT7; //P1.7 P1IE|=0x80; //P1.7 P1IES|=0x00; //P1.7 P1IFG=0; //P1.7, _EINT(); //}#pragma vector=PORT1_VECTOR__interrupt void Port_1(void){ P1IFG&=~BIT7; //P1.7/**/}

  • 4 1CPU CPU 2 1 2A 3B 4RTC

  • Timer_A 1 2PWM 3 48 516 6PWMPWMTimer_APWMPWM 12/CCR0Timer_ACCR01665536TARCCR0CCR00

  • :void zengjishu(){ TACTL=TASSEL1+TACLR; //ACLKTAR CCTL0=CCIE; // CCR0=200; //32768/200/2 TACTL|=MC_1; //Timer_A P1DIR|=BIT0; //P1.0 _EINT(); // }#pragma vertor =TIMERA0_VECTOR__interrupt void Timer_A(void) { P1OUT^=0X01; //P1.0 }

  • 3

    00XFFFF0CCR0

  • void lianxujishu(){ TACTL=TASSEL_1+TACLR; //ACLKTAR CCTL0=CCIE; // CCR0=1000; //32768/1000/2 TACTL|=MC_2; //Timer_A P1DIR|=BIT0; //P1.0 _EINT(); // }#pragma vertor =TIMERA0_VECTOR__interrupt void Timer_A(void) { P1OUT^=0X01; //P1.0 CCR0+=1000; }

  • 4//CCR00 TARCCR01CCR0CCIFG010TAIFG

  • 5/ 1/CCTLxCAP=1 TAR/CCRx 1 2 3 2/CCTLxCAP=0Timer_A /8

  • 5A/Dmsp430f449A/D1 1223844Vref65200Ks/s6 1 CONSEQ_0 2 CONSEQ_2 3CONSEQ_1 4CONSEQ_3ADC12

  • A/D 1 P6SEL|=0x01; //A/DA0P6.0; P6SEL|=BIT7; //A/DA7P6.7; 2ADC12 ADC12CTL0=ADC12ON; //ADC12; ADC12CTL0=SHT0_0; //4/200KHZ*1 ADC12CTL0=REFON; //2.5V; ADC12CTL0=MSC; /// 3 ADC12CTL1=SHP //SAMPCON ADC12CTL1=ADC12SSEL_0; //ADC12OSC200KHZ ADC12CTL1=CONSEQ_2// 4 ADC12CTL0|=ENC; //;

  • MSC=1SHP=1SHI 5 ADC12CTL0|=ADC12SC; // 1 void ADC_convert() { P6SEL|=0x01; //A/DA0P6.0; ADC12CTL0=ADC12ON+ SHT0_0; //ADC12,4*200KHZ*1 ADC12CTL1=SHP //SAMPCON ADC12CTL0|=ENC; // ADC12CTL0|=ADC12SC; // } int Read_result() { int result; result= ADC12MEM0; return (result); }

  • 2 Void ADC_convert(){ P6SEL|=0x02; //A/DA1; ADC12CTL0=ADC12ON+SHT0_8+MSC; //ADC124*mclk*64,2.5v ADC12CTL1=SHP+ADC12SSEL_2+CONSEQ_2; // ADC12CTL0|=ENC; // ADC12CTL0|=ADC12SC; //} int Read_result() { int result; result= ADC12MEM1; return (result); }

  • 3 void ADC_convert() { P6SEL|=0x0f; ADC12MCTL0=SREF_0+INCH_0; ADC12MCTL1=SREF_0+INCH_1; ADC12MCTL2=SREF_0+INCH_2; ADC12MCTL3=SREF_0+INCH_3+EOS; //EOS ADC12CTL0=ADC12ON+MSC+ SHT0_0; //ADC12,4*200KHZ*1 ADC12CTL1=SHP+CONSEQ_1 //SAMPCON ADC12CTL0|=ENC; // ADC12CTL0|=ADC12SC; // _EINT(); // }#pragma vector=ADC_VECTOR__interrupt void ADC12ISR(void){ result0 = ADC12MEM0; result1 = ADC12MEM1; result2 = ADC12MEM2; result3 = ADC12MEM3;

  • 4 void ADC_convert() { P6SEL|=0x0f; ADC12MCTL0=SREF_0+INCH_0; ADC12MCTL1=SREF_0+INCH_1; ADC12MCTL2=SREF_0+INCH_2; ADC12MCTL3=SREF_0+INCH_3+EOS; //EOS ADC12CTL0=ADC12ON+MSC+ SHT0_0; //ADC12,4*200KHZ*1 ADC12CTL1=SHP+CONSEQ_3 //SAMPCON ADC12CTL0|=ENC; // ADC12CTL0|=ADC12SC; // _EINT(); // }#pragma vector=ADC_VECTOR__interrupt void ADC12ISR(void){ result0 = ADC12MEM0; result1 = ADC12MEM1; result2 = ADC12MEM2; result3 = ADC12MEM3;

  • 6USART msp430f449USART0USART1 P2.4P2.5P4.0P4.1 UARTSPI 1 278 3 4 5

    USART

  • 1USART0USART1 USART1: P4SEL=0X03; P4DIR=0X01; //P4.0TXDP4.1RXD 2SWRST=1 U1CTL=SWRST; // USART, 3 UTCTL1=SSEL1; //UCLK=MCLK 4 ME2=UTXE1+URXE1; //RXD TXD 5 U1CTL=CHAR; //8,7 6 UBR=U1BR0+U1BR1; 3 U1BR0=0X1B; // U1BR1=0X00; // U1MCTL=0X03; //38400 7SWRST=0 U1CTL&=~SWRST; //SWRST1 8 IE2=URXIE1; //

  • 7PWMTimer_APWMvoid PWM_Creat(int a,int b){ TACTL=TASSEL_1+TACLR+ID_3; //ACLK8TAR CCR0=255; //32768/256/8/2=8HZ CCTL1=OUTMOD_7; CCR1=a; //a/256 CCTL2=OUTMOD_7; CCR2=b; //b/256 P1DIR|=BIT2; //CCR1 P1SEL|=BIT2; P2DIR|=BIT0; //CCR2 P2SEL|=BIT0; TACTL|=MC_1; //Timer_A }

  • 8 1#ifndef _ADC_H #define _ADC_H extern void ADC_convert(); extern int Read_result(); #endif 2.C

  • msp430launchpadMsp430g255311.8~3.6V2 280UA1MHZ2.2V 0.5UA RAM0.1UA3541us510A/D 200Ks/s616RISC6.25ns73/168UART/SPI/I2C911FLASH16KBRAM512B

  • Msp430g2553

  • Msp430g25531IO2345AD6PWM

  • 1IOP1P1P2IO2P3P4PP msp430f449P2.6P2.7IO P2SEL&=~(BIT6+BIT7);

  • IO

  • 2 1ACLK LFXT1CLK 32768HZ 2MCLK5 132768HZACLK 21MHZ: BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ;