TI 16 Bit RISC MSP430 Firmware Design - Develop Flow - 김형태 conan@firmwarebank.com
MSP430 Firmware 기획 선택 LCD Based MSP430 4xx Flash base 1.8V ~ 3.6V, up to 60kB/ Flash/ ROM 8MIPs MSP430 3xx ROM/OTP family MCU offer 2.5V-5.5V operation, up to 32kB, 4MIPS Non-LCD Based MSP430 1xx Flash/ ROM base 1.8V ~ 3.6V operation, up to 60kB, 8MIPs with Basic Clock
MSP 430 구입 - Training Board 구입 / 강의 www.firmwarebank.com - TI Chip 대리점안내 Hu&Power Tech, 02-2109-5433, 이종환과장 AVNET Korea, 031-738-1633, 유계환과장 - Community & 430 Study Group http://
Soft Tools
Hard Tools
View MSP-FET430x110 Graphic
View MSP-PRGS430 Graphic
View MSP-FET430P440 Graphic
9
Compiler 환경
Compiler 환경
Compiler 환경
Compiler 환경
Compiler 환경
Compiler 환경
Quadravox Compiler 환경
Quadravox Compiler 환경
Quadravox Compiler 환경
맛보기 Firmware
LCD 특징 디스플레이값을메모리에기록 자동신호발생 4 Type Static 2Mux ½ Bias 3Mux 1/3 Bias 4Mux 1/3 Bias 44X Device S0~S39
LCD Block
LCD Module
LCD 종류 LCD panel 종류 : TN (Twisted Nematic), HTN (High Twisted Nematic), STN (Super Twisted Nematic), FSTN (Film Super Twisted Nematic) 순서에따라가격높음 View Angle : 6 시 ( 아래에서위로경우 ), 12 시 ( 위에서아래로보는경우 ) Rear Polarizer Type : Reflective( 불투과 : Backlihgt 적용안하는경우 ), Transflective( 반투과 ), Transmissive( 투과 ) Display type : Positive, Negative Operating Temperature : 0~60C(Normal type), - 20~70C ( 고온용 ) Connector Type : Rubber(Zebra), Flexible(Heat seal), Metal Pin 자료출처 : siretech.co.kr 02-868-5002, 이기상차장
LCD SCH
LCD Display 정의 Code unsigned char digit_lcdm1[10] = {0x11,0x10,0x11,0x11,0x10,0x01,0x01,0x11,0x11,0x11}; unsigned char digit_lcdm2[10] = {0x11,0x01,0x10,0x11,0x01,0x11,0x11,0x01,0x11,0x11}; unsigned char digit_lcdm3[10] = {0x11,0x00,0x01,0x00,0x10,0x10,0x11,0x00,0x11,0x10}; unsigned char digit_lcdm4[10] = {0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x00,0x01,0x01};
LCD Code LCDM1 = digit_lcdm1[dig1]; // 0x11 LCDM2 = digit_lcdm2[dig1]; // 0x11 LCDM3 = digit_lcdm3[dig1]; // 0x11 LCDM4 = digit_lcdm4[dig1]; // 0 LCDM5 = digit_lcdm1[dig2]; LCDM6 = digit_lcdm2[dig2]; LCDM7 = digit_lcdm3[dig2]; LCDM8 = digit_lcdm4[dig2]; LCDM9 = digit_lcdm1[dig3]; LCDM10 = digit_lcdm2[dig3]; LCDM11 = digit_lcdm3[dig3]; LCDM12 = digit_lcdm4[dig3]; LCDM13 = digit_lcdm1[dig4]; LCDM14 = digit_lcdm2[dig4]; LCDM15 = digit_lcdm3[dig4]; LCDM16 = digit_lcdm4[dig4];
LCD, Buzzer, 7-Seg Code1 #include <msp430x43x.h> #include "D:\work\App\Header\IAR\MSP430_type.h" void Display(unsigned int value); void delay(unsigned int sleeptime); // Segment LCD 0, 9 unsigned char digit_lcdm1[10] = {0x11,0x10,0x11,0x11,0x10,0x01,0x01,0x11,0x11,0x11}; unsigned char digit_lcdm2[10] = {0x11,0x01,0x10,0x11,0x01,0x11,0x11,0x01,0x11,0x11}; unsigned char digit_lcdm3[10] = {0x11,0x00,0x01,0x00,0x10,0x10,0x11,0x00,0x11,0x10}; unsigned char digit_lcdm4[10] = {0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x00,0x01,0x01}; unsigned char seg7[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; unsigned char wd_time; uchar seg_count; unsigned int time;
Code2 void main(void){ WDTCTL = WDTPW + WDTHOLD; // WDT 비활성화 FLL_CTL0 = XCAP14PF; // Configure load caps LCDCTL = LCDON + LCDSTATIC + LCDP0 + LCDP2; // STK LCD STATIC, S0- S31 BTCTL = BTFRFQ1; // STK LCD freq P1DIR = BIT7 BIT6 BIT5 BIT4 BIT3 BIT2 BIT1 BIT0; // All LED 출력 P3DIR = BIT7; // P3.7 부저출력 P5SEL = 0xFC; // Common and Rxx all selected WDTCTL = WDT_ADLY_250; // WDT 250ms, ACLK, interval timer IE1 = WDTIE; // Enable WDT interrupt _EINT(); // Enable interrupts
Code3 LCDM1 = 0x00; LCDM2 = 0x00; LCDM3 = 0x00; LCDM4 = 0x00; LCDM5 = 0x00; LCDM6 = 0x00; LCDM7 = 0x00; LCDM8 = 0x00; LCDM9 = 0x00; LCDM10 = 0x00; LCDM11 = 0x00; LCDM12 = 0x00; LCDM13 = 0x00; LCDM14 = 0x00; LCDM15 = LCDM16 =0x00; // for initial wd_time = 0; seg_count=0;
Code4 while(1){// repeat forever } } if(wd_time>=4) { wd_time = 0; time++; if(time>=10000) time = 0; } Display(time); P1OUT = seg7[seg_count++]; // 7segment display delay(500); if(seg_count>9) seg_count=0;
Code5 void Display(unsigned int value){ unsigned char dig1, dig2, dig3, dig4; dig1 = (unsigned char)(value/1000); dig2 = (unsigned char)((value-dig1*1000)/100); dig3 = (unsigned char)((value-dig1*1000-dig2*100)/10); dig4 = (unsigned char)(value-dig1*1000-dig2*100-dig3*10); LCDM1 = digit_lcdm1[dig1]; LCDM2 = digit_lcdm2[dig1]; LCDM3 = digit_lcdm3[dig1]; LCDM4 = digit_lcdm4[dig1]; LCDM5 = digit_lcdm1[dig2]; LCDM6 = digit_lcdm2[dig2]; LCDM7 = digit_lcdm3[dig2]; LCDM8 = digit_lcdm4[dig2]; LCDM9 = digit_lcdm1[dig3]; LCDM10 = digit_lcdm2[dig3]; LCDM11 = digit_lcdm3[dig3]; LCDM12 = digit_lcdm4[dig3]; LCDM13 = digit_lcdm1[dig4]; LCDM14 = digit_lcdm2[dig4]; LCDM15 = digit_lcdm3[dig4]; LCDM16 = digit_lcdm4[dig4]; if(dig4==0){ P3OUT ^= BIT7; // P3.7 Buzzer Toggle, beep Sound } else P3OUT = (0xFFFF &!BIT7); }
Code6 #pragma vector=wdt_vector interrupt void uartreceivehandler( void ){ //interrupt[wdt_vector] void WD_TIMER(void) wd_time++; } void delay(unsigned int sleeptime){ unsigned int i1,i2; } for(i2=0;i2<sleeptime;i2++) for(i1=0;i1<=25;i1++) ;
LCD 코드실행동화상 LCD 실행동화상.MOV
Key Board SCH
KEY Board Code1 #include <msp430x43x.h> #include "D:\work\App\Header\IAR\MSP430_type.h" unsigned char Key_processing(void); void main(void){ int index = 0; // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 unsigned char Seg_No[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; } WDTCTL = WDTPW + WDTHOLD; // WDT 타이머비활성화 P1DIR = 0xff; // P1.0 ~ 7 FND 출력 P3DIR = BIT2 BIT1 BIT0; // P3.0 ~ 2 Key matrix 출력, P3.3 ~ 5 Key matrix 입력 for (;;){ // repeat forever index = Key_processing(); P1OUT = Seg_No[index]; }
KEY Board Code2 unsigned char Key_processing(void){ unsigned char x_scan, y_scan, button_num; unsigned char temp; button_num = 0; temp = 0; for(x_scan=0; x_scan<3; x_scan++){ P3OUT = 0x01 << x_scan;// 신호송출 for(y_scan=0; y_scan<3; y_scan++){ button_num++; if(p3in&(0x08<<y_scan))// 신호수신 / 비교 return temp = button_num; } } return temp; }
DC Motor L298
L298
Motor SCH U2 MSP430_449/448/447 P5.1/SEG0 12 P5.0/SEG1 13 SEG2 14 SEG3 15 SEG4 16 SEG5 17 SEG6 18 SEG7 19 SEG8 20 SEG9 21 SEG10 22 SEG11 23 SEG12 24 SEG13 25 SEG14 26 SEG15 27 SEG16 28 SEG17 29 SEG18 30 SEG19 31 SEG20 32 SEG21 33 SEG22 34 SEG23 35 SEG24 36 SEG25 37 SEG26 38 SEG27 39 SEG28 40 SEG29 41 SEG30 42 SEG31 43 SEG32 44 SEG33 45 P4.7/SEG34 46 P4.6/SEG35 47 P4.5/SEG36 48 P4.4/SEG37 49 P4.3/SEG38 50 P4.2/SEG39 51 COM0 52 P5.2/COM1 53 P5.3/COM2 54 P5.4/COM3 55 P1.0/TA0 87 P1.1/TA0/MCLK 86 P1.2/TA1 85 P1.3/TBOUTH/SVSOUT 84 P1.4/TBCLK/SMCLK 83 P1.5/TACLK/ACLK 82 P1.6/CA0 81 P1.7/CA1 80 P2.0/TA2 79 P2.1/TB0 78 P2.2/TB1 77 P2.3/TB2 76 P2.4/UTXD0 75 P2.5/URXD0 74 P2.6/CAOUT 73 P2.7/ADC12CLK 72 P3.0/STE0 71 P3.1/SIMO0 70 P3.2/SOMI0 69 P3.3/UCLK0 68 P3.4 67 P3.5 66 P3.6 65 P3.7 64 P6.0/A0 95 P6.1/A1 96 P6.2/A2 97 P6.3/A3 2 P6.4/A4 3 P6.5/A5 4 P6.6/A6 5 P6.7/A7/SVSin 6 P4.0/UTXD1 63 P4.1/URXD1 62 RST/NMI 94 TCK 93 TMS 92 TDI 91 TDO/TDI 90 Xin 8 Xout/TCLK 9 VREF+ 7 VEREF+ 10 VREF-/VEREF- 11 XT2in 89 XT2out 88 CVCC1 1 DVCC2 60 AVCC 100 DVSS1 99 DVSS2 61 AVSS 98 P5.7/R33 59 P5.6/R23 58 P5.5/R13 57 R03 56 3_3V AVcc 3_3V R6 0 C14 104 AVcc PWM1 PWM2 MOTEN1 MOTEN2
DC Motor SCH
Motor Code1 #include <msp430x43x.h> #include "D:\work\App\Header\IAR\MSP430_type.h" void Sleep(unsigned int sleeptime); void main(void){ unsigned char pwm1, pwm2; pwm1 = 150; pwm2 = 105; WDTCTL = WDTPW +WDTHOLD; // WDT 비활성화 P1DIR = BIT1 BIT0; // P1.0, P1.1 출력, P1.2 스위치입력 P2DIR = BIT3 BIT2 BIT1 BIT0; // P2.3 ~ 0 출력, Motor Direction and Enable P2OUT &= ~(BIT3 BIT1); // Moter Enable Off P2SEL = BIT2 BIT0; // P2.2 TB1 and P2.0 TA2 P2OUT = 0x0a; // 0000 1010, Motor Reverse ON TACTL = TASSEL_1 + TACLR; // ACLK, Clear TAR TACCR0 = 256-1; // PWM Period/2 TACCTL2 = OUTMOD_6; // CCR2 Toggle/set TACCR2 = pwm1; // CCR2 PWM duty cycle TACTL = MC1 + MC0; // Start Timer_A in up-down mode
Motor Code2 TBCTL = TBSSEL_1 + TBCLR; // ACLK, Clear TBR TBCCR0 = 256-1; // PWM Period/2 TBCCTL1 = OUTMOD_6; // CCR1 reset/set TBCCR1 = pwm2; // CCR1 PWM duty cycle TBCTL = MC1 + MC0; // Start Timer_B in updown mode
Motor Code3 for (;;) { // repeat forever if(p1in&bit2) { // 스위치를누르지않으면.. P1OUT ^= BIT0; // P1.0 포트의 LED 가 Toggle P1OUT = BIT1; // P1.1 포트의 LED 가 off pwm1 = 150; TACCR2 = pwm1; // CCR2 PWM duty cycle } else { P1OUT ^= BIT1; // P1.1 포트의 LED 가 Toggle P1OUT = BIT0; // P1.0 포트의 LED 가 off if(pwm1<255) { pwm1++; TACCR2 = pwm1; // CCR2 PWM duty cycle } } Sleep(1000); // Delay } }
온도검출 SCH U2 MSP430_449/448/447 P5.1/SEG0 12 P5.0/SEG1 13 SEG2 14 SEG3 15 SEG4 16 SEG5 17 SEG6 18 SEG7 19 SEG8 20 SEG9 21 SEG10 22 SEG11 23 SEG12 24 SEG13 25 SEG14 26 SEG15 27 SEG16 28 SEG17 29 SEG18 30 SEG19 31 SEG20 32 SEG21 33 SEG22 34 SEG23 35 SEG24 36 SEG25 37 SEG26 38 SEG27 39 SEG28 40 SEG29 41 SEG30 42 SEG31 43 SEG32 44 SEG33 45 P4.7/SEG34 46 P4.6/SEG35 47 P4.5/SEG36 48 P4.4/SEG37 49 P4.3/SEG38 50 P4.2/SEG39 51 COM0 52 P5.2/COM1 53 P5.3/COM2 54 P5.4/COM3 55 P1.0/TA0 87 P1.1/TA0/MCLK 86 P1.2/TA1 85 P1.3/TBOUTH/SVSOUT 84 P1.4/TBCLK/SMCLK 83 P1.5/TACLK/ACLK 82 P1.6/CA0 81 P1.7/CA1 80 P2.0/TA2 79 P2.1/TB0 78 P2.2/TB1 77 P2.3/TB2 76 P2.4/UTXD0 75 P2.5/URXD0 74 P2.6/CAOUT 73 P2.7/ADC12CLK 72 P3.0/STE0 71 P3.1/SIMO0 70 P3.2/SOMI0 69 P3.3/UCLK0 68 P3.4 67 P3.5 66 P3.6 65 P3.7 64 P6.0/A0 95 P6.1/A1 96 P6.2/A2 97 P6.3/A3 2 P6.4/A4 3 P6.5/A5 4 P6.6/A6 5 P6.7/A7/SVSin 6 P4.0/UTXD1 63 P4.1/URXD1 62 RST/NMI 94 TCK 93 TMS 92 TDI 91 TDO/TDI 90 Xin 8 Xout/TCLK 9 VREF+ 7 VEREF+ 10 VREF-/VEREF- 11 XT2in 89 XT2out 88 CVCC1 1 DVCC2 60 AVCC 100 DVSS1 99 DVSS2 61 AVSS 98 P5.7/R33 59 P5.6/R23 58 P5.5/R13 57 R03 56 3_3V AVcc THERM
Sensor SCH
온도검출 Code1 void mpu_initial(void){ LCDM1 = 0x00; // LCD 초기값설정중략 WDTCTL = WDTPW + WDTHOLD; // WDT 비활성화 FLL_CTL0 = XCAP14PF; // Configure load caps LCDCTL = LCDON + LCDSTATIC + LCDP0 + LCDP2; // STK LCD STATIC, S0-S31 BTCTL = BTFRFQ1; // STK LCD freq P1OUT = BIT7 BIT6 BIT5 BIT4 BIT3 BIT2 BIT1 BIT0;// FND All OFF P1DIR = BIT7 BIT6 BIT5 BIT4 BIT3 BIT2 BIT1 BIT0; // All LED 출력 Setting WDTCTL = WDT_ADLY_250; // WDT 250ms, ACLK, interval timer IE1 = WDTIE; // Enable WDT interrupt P6SEL = BIT3; // Enable A/D channel inputs ADC12CTL0 = ADC12ON+MSC+SHT0_8; // Turn on ADC12, set sampling time ADC12CTL1 = SHP+CONSEQ_3; // Use sampling timer, single sequence ADC12MCTL0 = INCH_0; // ref+=avcc, channel = A0 ADC12MCTL1 = INCH_1; // ref+=avcc, channel = A1 ADC12MCTL2 = INCH_2; // ref+=avcc, channel = A2 ADC12MCTL3 = INCH_3+EOS; // ref+=avcc, channel = A0 ADC12IE = BIT3; // Enable ADC12IFG.3 ADC12CTL0 = ENC; // Enable conversions _EINT(); // Enable interrupts }
온도검출 Code2 void Display(unsigned int value){ dig1 = (unsigned char)(value/1000); dig2 = (unsigned char)((value-dig1*1000)/100); dig3 = (unsigned char)((value-dig1*1000-dig2*100)/10); dig4 = (unsigned char)(value-dig1*1000-dig2*100-dig3*10); LCDM1 = digit_lcdm1[dig1]; LCDM2 = digit_lcdm2[dig1]; LCDM3 = digit_lcdm3[dig1]; LCDM4 = digit_lcdm4[dig1]; LCDM5 = digit_lcdm1[dig2]; LCDM6 = digit_lcdm2[dig2]; LCDM7 = digit_lcdm3[dig2]; LCDM8 = digit_lcdm4[dig2]; LCDM9 = digit_lcdm1[dig3]; LCDM10 = digit_lcdm2[dig3]; LCDM11 = digit_lcdm3[dig3]; LCDM12 = digit_lcdm4[dig3]; LCDM13 = digit_lcdm1[dig4]; LCDM14 = digit_lcdm2[dig4]; LCDM15 = digit_lcdm3[dig4]; LCDM16 = digit_lcdm4[dig4]; } #pragma vector=adc_vector interrupt void ADC12ISR( void ){ } results = ADC12MEM3; // Move results, IFG is cleared #pragma vector=wdt_vector interrupt void uartreceivehandler( void ){ //interrupt[wdt_vector] void WD_TIMER(void) // wd_time++; }
온도검출 Code3 void main(void){ mpu_initial(); for (;;) { dig1 = (unsigned char)(results/1000); dig2 = (unsigned char)((results-dig1*1000)/100); dig3 = (unsigned char)((results-dig1*1000-dig2*100)/10); P1OUT=Seg_No[dig3]; Sleep(10); Display(results); ADC12CTL0 = ADC12SC; // Start conversion Sleep(10); } } void Sleep(unsigned int sleeptime){ unsigned int i1,i2; } for(i2=0;i2<sleeptime;i2++) for(i1=0;i1<=25;i1++) ;
MSP 430 Study Group
추가정보 이번발표자료다운로드 http:// 430 StudyGroup MSP430_040521