User Tools

Site Tools


Writing /home/donghee/dh8.kr/wiki/data/meta/markdown.meta failed
markdown

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
markdown [2012/04/29 09:11] dongheemarkdown [2026/06/11 05:52] (current) – external edit 127.0.0.1
Line 1: Line 1:
-##txt = getText()+<markdown>
  
 +# 하드웨어 만들기
 + - RF
 + - EPS
 + - PAYLOAD
 + - 솔라셀
 +
 +# 소프트웨어(주요기능)
 +
 + 1. EPS 제어(충전, 리셋)
 + 1. RF에서 RX로 신호를 받아서 메시지 등록, 
 + 1. 다른칩 죽었는지 서로 감시
 + 1. 시간되면 LED 깜박임
 + 1. 인공위성정보 비콘으로 보냄
 + 1. 전체 reset 하는 command.
 + 1. 인자 업데이트 
 +
 +#### RF/BEACON
 +1. 비콘의 TX
 + - 입력: 배터리 레벨, VBUS, 솔라패널 전류, 베터리 충전 여부, COMS, PAYLOAD 모듈동작상태, 온도,   
 + - 처리: RF칩에서 받아 들이는 신호로 만들기.
 + - 출력: RF칩에 신호보내기.
 +
 +#### RF/COMS
 +1. COMS RX
 + - 입력: RF칩에서 신호 받음 
 + - 처리: 입력 받은 신호를 I2C로 가공
 + - 출력: OBC에 I2C로 받은 신호 전달.(예약 메시지)
 +1. OBC 감시
 + - 입력: OBC에서 신호를 받는다.
 + - 처리: OBC에 신호가 있는지 없는지 체크 
 + - 출력: 입력 신호가 없으면 OBC에 리셋을 날려줌.
 +
 +#### OBC
 +1. EPS 전원제어 (베터리, 수퍼캡 충전 방전)
 + - 입력: 베터리 전압, 베터리 충전상태, 수퍼캡 충전상태, 수퍼캡 전압 
 + - 처리: 
 +
 +1. 안테나 deployment 실행
 + - 처리: 20분이 지나면 안타나 deployment 핀 신호 인가
 + - 출력: deployment 완료 플래그 설정 (플래쉬메모리) 
 +
 +1. COMS, BEACON, PAYLOAD 감시
 +
 +1. 메시지 스케쥴링 예약: COMS RX에서 메시지 받기 
 + - 입력: 예약 메시지 신호 받기
 + - 처리: 시간을 파싱하여, 플래쉬 메모리에 스케쥴 예약
 + - 출력: 예약 완료 메시지 RX에 보내기
 +1. 메시지 예약 실행
 + - 입력: 시간, 슈퍼캡이 충전 되어 있는가?, 밤/낮, 회전상태 
 + - 처리: 시간 보면서 예약 테이블에 스케쥴링된 메시지 실행 
 + - 출력: PAYLOAD에 I2C로 메시지 보내기
 +1. 메시지 예약 삭제
 +
 +#### LED: 모스코드
 +1. I2C로 받은 메시지를 LED 키기.
 + - 입력: OBC에서 받은 메시지
 + - 처리: I2C로 받은 메시지를 모스 코드로 바꾼다. 
 + - 출력: 모스신호에 따라 LED 키기
 +2. PWM 으로 LED 제어 
 + - ?
 +
 +## 코드 
 +morse, uart0 
 +
 + //******************************************************************************
 + //  MSP-FET430P140 Demo - USART1, Ultra-Low Pwr UART 9600 Echo ISR, 32kHz ACLK
 + //
 + //  Description: Echo a received character, RX ISR used. Normal mode is LPM3,
 + //  USART1 RX interrupt triggers TX Echo.
 + //  ACLK = UCLK1 = LFXT1 = 32768, MCLK = SMCLK = DCO~ 800k
 + //  Baud rate divider with 32768hz XTAL @9600 = 32768Hz/9600 = 3.41 (0003h 4Ah )
 + //  //* An external watch crystal is required on XIN XOUT for ACLK *//
 + //
 + //
 + //                MSP430F149
 + //            -----------------
 + //        /|\|              XIN|-
 + //         | |                 | 32kHz
 + //         --|RST          XOUT|-
 + //                           |
 + //                       P3.4|----------->
 + //                           | 9600 - 8N1
 + //                       P3.5|<-----------
 + //
 + //
 + //  M. Buccini
 + //  Texas Instruments Inc.
 + //  Feb 2005
 + //  Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.21A
 + //******************************************************************************
 +
 + #include  <msp430x14x.h>
 + #include "morse.h"
 +
 + char message[255];
 + uint8_t step = 0;
 + uint8_t sending = 0;
 +
 + void main(void)
 + {
 +   volatile unsigned int i;
 +   WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer
 +   P6DIR |= 0x01;
 +
 +   WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
 +   P3SEL |= 0x30;                            // P3.4,5 = USART0 TXD/RXD
 +   ME1|= UTXE0 + URXE0;                     // Enable USART0 TXD/RXD
 +   UCTL0 |= CHAR;                            // 8-bit character
 +   UTCTL0 |= SSEL0;                          // UCLK = ACLK
 +   UBR00 = 0x03;                             // 32k/9600 - 3.41
 +   UBR10 = 0x00;                             //
 +   UMCTL0 = 0x4A;                            // Modulation
 +   UCTL0 &= ~SWRST;                          // Initialize USART state machine
 +   IE1 |= URXIE0;                            // Enable USART0 RX interrupt
 +
 + // _BIS_SR(LPM0_bits + GIE);                 // Enter LPM3 w/ interrupt
 +   _EINT();
 +
 +   while (1) {
 +   if (sending == 1) {
 +   for(i=0; i < step;i++ ) {
 + ascii(message[i]);
 +   }
 +   step=0;
 +   sending=0;
 +   }
 +   }
 + }
 +
 + #pragma vector=USART0RX_VECTOR
 + __interrupt void usart0_rx (void)
 + {
 +
 +   while (!(IFG1 & UTXIFG0));                // USART1 TX buffer ready?
 +   TXBUF0 = RXBUF0;                          // RXBUF1 to TXBUF1
 +   message[step] = RXBUF0;
 +   step++;
 +   if (RXBUF0 == 13)   // CR
 +   {
 +   P6OUT ^= 0x01;
 +   sending = 1;
 +   }
 + }
 +
 +
 +
 + #include "morse.h"
 +
 + //uint8_t done = 0b10000000;
 + uint8_t done = 0x80;
 +
 + uint8_t output_pin;
 +
 + void delay(void)
 + {
 +     volatile unsigned int i;
 +     i = 15000;                              // Delay
 +     do (i--);
 +     while (i != 0);
 + }
 +
 + void mark(uint8_t t)
 + {
 + volatile unsigned int i;
 + for(i = 0; i < t; i++)
 + {
 + P6OUT &= ~0x01;                         // Turn On
 + delay();
 + }
 + P6OUT |= 0x01;                          // Turn Off
 + delay();
 + }
 +
 + void space(uint8_t t)
 + {
 + volatile unsigned int i;
 + for(i = 0; i < t; i++)
 + {
 + P6OUT |= 0x01;
 + delay();
 + }
 + }
 +
 + void morse(uint8_t m)
 + {
 + while (m != done) {
 +     mark(m & done ? 3 : 1);
 +     space(1);
 +     m = m << 1;
 + }
 + space(3);
 + }
 +
 +
 + void ascii(char c) {
 + uint8_t number_code[] = {
 + // 0b11111100, 0b01111100, 0b00111100, 0b00011100, 0b00001100, 0b00000100,
 + // 0b10000100, 0b11000100, 0b11100100, 0b11110100 // 0-9
 + 0xfc, 0x7c, 0x3c, 0x1c, 0xc, 0x4, 0x84, 0xc4, 0xe4, 0xf4
 + };
 +
 + uint8_t alphabet_code[] = {
 + // 0b01100000, 0b10001000, 0b10101000, 0b10010000, 0b01000000, 0b00101000,
 + // 0b11010000, 0b00001000, 0b00100000, 0b01111000, 0b10110000, 0b01001000,
 + // 0b11100000, 0b10100000, 0b11110000, 0b01101000, 0b11011000, 0b01010000,
 + // 0b00010000, 0b11000000, 0b00110000, 0b00011000, 0b01110000, 0b10011000,
 + // 0b10111000, 0b11001000 // A-Z
 + 0x60, 0x88, 0xa8, 0x90, 0x40, 0x28, 0xd0, 0x8, 0x20, 0x78, 0xb0, 0x48, 0xe0, 0xa0, 0xf0, 0x68, 0xd8, 0x50, 0x10, 0xc0, 0x30, 0x18, 0x70, 0x98, 0xb8, 0xc8
 + };
 +
 + if (c >= '0' && c <= '9') {
 + morse(number_code[c- '0']);
 + } else if (c >= 'a' && c <= 'z') {
 + morse(alphabet_code[c - 'a']);
 + } else if (c == ' ') {
 + space(7);
 + } else {
 + morse(done);
 + }
 + }
 +
 +----------
 +#### 타이머
 +**watchdog timer**
 +
 + #include  <msp430x14x.h>
 +
 + void main(void)
 + {
 +   WDTCTL = WDT_MDLY_32;                     // Set Watchdog Timer interval to ~30ms
 +   IE1 |= WDTIE;                             // Enable WDT interrupt
 +   P6DIR |= 0x01;                            // Set P1.0 to output direction
 +
 +   _BIS_SR(LPM0_bits + GIE);                 // Enter LPM0 w/ interrupt
 + }
 +
 + // Watchdog Timer interrupt service routine
 + #pragma vector=WDT_VECTOR
 + __interrupt void watchdog_timer(void)
 + {
 +   P6OUT ^= 0x01;                            // Toggle P1.0 using exclusive-OR
 + }
 +
 +
 +**그냥 타이머**
 + #include  <msp430x14x.h>
 +
 + void main(void)
 + {
 +   WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
 +   P6DIR |= 0x01;                            // P1.0 output
 +   CCTL0 = CCIE;                             // CCR0 interrupt enabled
 +   CCR0 = 50000;
 +   TACTL = TASSEL_2 + MC_2;                  // SMCLK, contmode
 +
 +   _BIS_SR(LPM0_bits + GIE);                 // Enter LPM0 w/ interrupt
 + }
 +
 + // Timer A0 interrupt service routine
 + #pragma vector=TIMERA0_VECTOR
 + __interrupt void Timer_A (void)
 + {
 +   P6OUT ^= 0x01;                            // Toggle P1.0
 +   CCR0 += 50000;                            // Add Offset to CCR0
 + }
 +
 +PWM
 +
 + //*******************************************************************************
 + //  MSP-FET430P140 Demo - Timer_A, PWM TA1-2, Up Mode, 32kHz ACLK
 + //
 + //  Description: This program generates two PWM outputs on P1.2,3 using
 + //  Timer_A configured for up mode. The value in CCR0, 512-1, defines the PWM
 + //  period and the values in CCR1 and CCR2 the PWM duty cycles. Using 32kHz
 + //  ACLK as TACLK, the timer period is 15.6ms with a 75% duty cycle on P1.2
 + //  and 25% on P1.3. Normal operating mode is LPM3.
 + //  ACLK = TACLK = LFXT1 = 32768Hz, MCLK = default DCO ~800kHz.
 + //  //* External watch crystal on XIN XOUT is required for ACLK *//
 + //
 + //               MSP430F149
 + //            -----------------
 + //        /|\|              XIN|-
 + //         | |                 | 32kHz
 + //         --|RST          XOUT|-
 + //                           |
 + //                   P1.2/TA1|--> CCR1 - 75% PWM
 + //                   P1.3/TA2|--> CCR2 - 25% PWM
 + //
 + //  M. Buccini
 + //  Texas Instruments Inc.
 + //  Feb 2005
 + //  Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.21A
 + //******************************************************************************
 +
 + #include  <msp430x14x.h>
 +
 + void main(void)
 + {
 +   WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
 +   P1DIR |= 0x0C;                            // P1.2 and P1.3 output
 +   P1SEL |= 0x0C;                            // P1.2 and P1.3 TA1/2 otions
 +   CCR0 = 512-1;                             // PWM Period
 +   CCTL1 = OUTMOD_7;                         // CCR1 reset/set
 +   CCR1 = 384;                               // CCR1 PWM duty cycle
 +   CCTL2 = OUTMOD_7;                         // CCR2 reset/set
 +   CCR2 = 128;                               // CCR2 PWM duty cycle
 +   TACTL = TASSEL_1 + MC_1;                  // ACLK, up mode
 +
 +   _BIS_SR(LPM3_bits);                       // Enter LPM3
 + }
 +
 +
 +#### Low power mode (3 or 4)
 +
 +
 +#### 핀인터럽트
 + (전체핀)
 + (하나핀)?
 +
 +external interupt
 + latch up?
 +----
 + port 1,2,3 이 가능 .
 +
 +
 +#### ADC
 + //******************************************************************************
 + //  MSP-FET430P140 Demo - ADC12, Sample A0, Set P1.0 if A0 > 0.5*AVcc
 + //
 + //  Description: A single sample is made on A0 with reference to AVcc.
 + //  Software sets ADC10SC to start sample and conversion - ADC12SC
 + //  automatically cleared at EOC. ADC12 internal oscillator times sample (16x)
 + //  and conversion. In Mainloop MSP430 waits in LPM0 to save power until ADC12
 + //  conversion complete, ADC12_ISR will force exit from LPM0 in Mainloop on
 + //  reti. If A0 > 0.5*AVcc, P1.0 set, else reset.
 + //
 + //                MSP430F149
 + //             -----------------
 + //         /|\|              XIN|-
 + //          | |                 |
 + //          --|RST          XOUT|-
 + //            |                 |
 + //      Vin-->|P6.0/A0      P1.0|--> LED
 + //
 + //  M. Buccini
 + //  Texas Instruments Inc.
 + //  Feb 2005
 + //  Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.21A
 + //******************************************************************************
 +
 + #include  <msp430x14x.h>
 +
 + void main(void)
 + {
 +   WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
 +   ADC12CTL0 = SHT0_2 + ADC12ON;             // Set sampling time, turn on ADC12
 +   ADC12CTL1 = SHP;                          // Use sampling timer
 +   ADC12IE = 0x01;                           // Enable interrupt
 +   ADC12CTL0 |= ENC;                         // Conversion enabled
 +   P6SEL |= 0x02;                            // P6.0 ADC option select
 +   P6DIR |= 0x01;                            // P1.0 output
 +
 +   for (;;)
 +   {
 +     ADC12CTL0 |= ADC12SC;                   // Sampling open
 +     _BIS_SR(CPUOFF + GIE);                  // LPM0, ADC12_ISR will force exit
 +   }
 + }
 +
 + // ADC12 interrupt service routine
 + #pragma vector=ADC12_VECTOR
 + __interrupt void ADC12_ISR (void)
 + {
 +     if (ADC12MEM0 < 0x7FF)
 +       P6OUT &= ~0x01;                       // Clear P1.0 LED off
 +     else
 +       P6OUT |= 0x01;                        // Set P1.0 LED on
 +     _BIC_SR_IRQ(CPUOFF);                    // Clear CPUOFF bit from 0(SR)
 + }
 +
 +#### UART & Serial port
 + //******************************************************************************
 + //  MSP-FET430F149 Demo - ADC12, Sample A1, Send the level at Serial Port
 + //
 + //  Description: A single sample is made on A1 with reference to AVcc.
 + //  Software  start sample and conversion - Send out the
 + //  Analog voltage level to the serial port as two bytes.
 + //
 + //Additionally if the voltage is over 0.5*Vcc it makes LED at P6.2 glow
 + //
 + //                MSP430F149
 + //             -----------------
 + //         /|\|              XIN|-
 + //          | |                 |
 + //          --|RST          XOUT|-
 + //            |                 |
 + //      Vin-->|P6.1/A1      P6.2|-->
 + //            |                 |
 + //            |             P3.4|----------->
 + //            |                 | 9600 - 8N1
 + //            |             P3.5|<-----------
 + //
 + // referencedesigner.com
 + // Some of the Original codes are from Texas Instruments
 + //******************************************************************************
 +
 + #include  <msp430x14x.h>
 +
 + unsigned int delay ( unsigned int x)
 + {
 + unsigned int i,j;
 + for (i = 0; i<= x; i++)
 +   {
 +   for(j=0;j<=1000; j++) ;
 +   }
 + return 0;
 + }
 +
 +
 + void main(void)
 + {
 +
 +   WDTCTL = WDTPW + WDTHOLD;                 // Stop Watch Dog Timer
 +   ADC12CTL0 = SHT0_2 + ADC12ON;             // Set sampling time, turn on ADC12
 +   ADC12CTL1 =  SHP;
 +   ADC12IE = 0x01;                           // Enable interrupt
 +   ADC12MCTL0 = 0x01 ;
 +   ADC12CTL0 |= ENC ;                        // Conversion enabled
 +   P6SEL |= 0x02 ;                          // P6.1 ADC option select
 +   P6DIR |= 0x04;                           // P6.2 is output for LED
 +
 +   // Serial Port Settings
 +
 +   P3SEL |= 0x30;                            // P3.4,5 = USART0 TXD/RXD
 +   ME1 |= UTXE0 + URXE0;                     // Enable USART0 TXD/RXD
 +   UCTL0 |= CHAR;                            // 8-bit character
 +   UTCTL0 |= SSEL0;                          // UCLK = ACLK
 +   UBR00 = 0x03;                             // 32k/9600 - 3.41
 +   UBR10 = 0x00;                             //
 +   UMCTL0 = 0x4A;                            // Modulation
 +   UCTL0 &= ~SWRST;                          // Initialize USART state machine
 +   IE1 |= URXIE0;                            // Enable USART0 RX interrupt
 +
 +   for (;;)
 +   {
 +     // This should actually happen in a timer interrupt where
 +     // we may like to sample only once in, say 1 second
 +     delay(500);
 +     ADC12CTL0 |= ADC12SC;                   // Sampling open
 +     _BIS_SR(CPUOFF + GIE);                  // LPM0, ADC12_ISR will force exit
 +   }
 + }
 +
 + // ADC12 interrupt service routine
 +
 + #pragma vector=ADC12_VECTOR
 + __interrupt void ADC12_ISR (void)
 + {
 + unsigned short lResultRSSI ;
 + unsigned char part1, part2;
 +
 +     if (ADC12MEM0 < 0x7FF)
 +       P6OUT &= ~0x04;                       // Clear P6.2 - LED off
 + else
 +       P6OUT |= 0x04;                        // Set P6.2 - LED on
 +     _BIC_SR_IRQ(CPUOFF);                    // Clear CPUOFF bit from 0(SR)
 +
 +    lResultRSSI = ADC12MEM0 ;                          // RXBUF0 to TXBUF0
 +
 +   part1 = (lResultRSSI & 0x00FF); // lsb
 +   part2 = (lResultRSSI & 0xFF00) >> 8; // msb
 +
 +   while (!(IFG1 & UTXIFG0));
 +   TXBUF0 = part2; // We send MSB first
 +
 +   while (!(IFG1 & UTXIFG0));
 +   TXBUF0 = part1;
 + }
 +
 +
 +#### PWM
 + - hardware pwm: http://gushh.net/blog/msp430-servo/
 + - PWM DC Motor Control Using Timer_A of the MSP430: http://www.ti.com/lit/an/slaa120/slaa120.pdf
 +
 +#### I2C
 + - EEPROM (메시지, 
 + 
 +
 +#### SPI
 +
 +#### 타이머 인터럽트: counter
 +
 +#### pulseIn? RF?
 +
 +#### delay 구현 조사
 +
 + static void __inline__ delay(register unsigned int n)
 + {
 +     __asm__ __volatile__ (
 + "1: \n"
 + " dec %[n] \n"
 + " jne 1b \n"
 +         : [n] "+r"(n));
 + }
 +
 + void delay_ms(unsigned int n)
 + {
 +   while (n--)
 +   {
 +     delay(F_CPU/4000);
 +   }
 + }
 +
 +#### RTC
 +Software Realtime Clock
 +http://www.43oh.com/forum/viewtopic.php?f=10&t=2477
 +</markdown>
markdown.1335690696.txt.gz · Last modified: 2026/06/11 05:52 (external edit)