User Tools

Site Tools


ossicubesat

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
ossicubesat [2012/05/06 06:56] dongheeossicubesat [2018/07/18 14:10] (current) – external edit 127.0.0.1
Line 53: Line 53:
  - 출력: PAYLOAD에 I2C로 메시지 보내기  - 출력: PAYLOAD에 I2C로 메시지 보내기
 1. 메시지 예약 삭제 1. 메시지 예약 삭제
 +
 +
 +
 +read button and led on
 +
 +#include  <msp430x16x.h>
 +
 +void main (void)
 +{
 +  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
 +  P6DIR |= BIT0;
 +  P1OUT = BIT2; //pull up
 +
 +  while(1)
 +  {
 +
 +   if((P6IN & BIT1) == 0) { // LOW?
 +   P6OUT |= BIT0;
 +   } else {
 +   P6OUT &= ~BIT0;
 +   }
 +   }
 +}
  
 #### LED: 모스코드 #### LED: 모스코드
Line 324: Line 347:
 ---- ----
  port 1,2,3 이 가능 .  port 1,2,3 이 가능 .
 +
 +
  
  
Line 504: Line 529:
  
 Setting I2CEN = 0 has the following effects: Setting I2CEN = 0 has the following effects:
 +
  - I2C communication stops  - I2C communication stops
  - SDA and SCL are high impedance  - SDA and SCL are high impedance
Line 512: Line 538:
  - I2COA, I2CSA, I2CIE, I2CIFG, and I2CIV registers are unchanged  - I2COA, I2CSA, I2CIE, I2CIFG, and I2CIV registers are unchanged
  
- +When I2RM=1, I2CSTP must be set before the last I2CDR value is written. Othwerwise, correct STOP generation will not occur.
-*When I2RM=1, I2CSTP must be set before the last I2CDR value +
-is written. Othwerwise, correct STOP generation will not occur.+
  
  
 RXRDYIFG  RXRDYIFG 
  
-Receive ready interrupt/status. This flag is set when the I2C module +Receive ready interrupt/status. This flag is set when the I2C module has received new data. RXRDYIFG is automatically cleared when 
-has received new data. RXRDYIFG is automatically cleared when +I2CDR is read and the receive buffer is empty. A receiver overrun is indicated if bit I2CRXOVR = 1. RXRDYIFG is used in receive mode
-I2CDR is read and the receive buffer is empty. A receiver overrun is +
-indicated if bit I2CRXOVR = 1. RXRDYIFG is used in receive mode+
 only. only.
  
 TXRDYIFG TXRDYIFG
  
-Transmit ready interrupt/status. This flag is set when the I2C module +Transmit ready interrupt/status. This flag is set when the I2C module is ready for new transmit data (master transmit mode) or when 
-is ready for new transmit data (master transmit mode) or when +another master is requesting data (slave transmit mode). TXRDYIFG is automatically cleared when I2CDR and the transmit buffer are full. 
-another master is requesting data (slave transmit mode). TXRDYIFG +A transmit underflow is indicated if I2CTXUDF = 1. Unused in receive mode.
-is automatically cleared when I2CDR and the transmit buffer are full. +
-A transmit underflow is indicated if I2CTXUDF = 1. Unused in receive +
-mode.+
  
 eeprom eeprom
Line 1140: Line 1159:
  
 uart to 7020 uart to 7020
-음 그런데 morse 신호 처음 부분이 잘린다. 
  
 main.c main.c
Line 1434: Line 1452:
  }  }
  }  }
 +
 +====== 7021-n ======
 +
 +4k일때는 잘되는것 같은데, 9.6k 일때 핀 인터럽트가 밀리는것 같다. 
 +
 + #include  <msp430x16x.h>
 + #include "morse.h"
 + #include "rf.h"
 +
 + char message[255];
 + //char _message[255] = {'h','e','l','l','o',' ','o','s','s','i',' ', '1'};
 +
 + char _message[255] = {'a','b','c', 'd','e','f','g','h','i','j','k','l'};
 +
 + uint8_t step = 0;
 + uint8_t sending = 0;
 + int i =7;
 + int m =0;
 +
 + void initUart() {
 +   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
 + }
 +
 + void init_txrx_interrupt()
 + {
 +   P1OUT = BIT2; //pull up
 +   P1IE |= BIT2; // interrupt enable
 +   P1IES |= BIT2; // interrupt hi/lo falling edge
 +   //P1IES &= ~BIT2; // interrupt lo/hi edge
 +   P1IFG &= ~BIT2; // P1.2 IFG cleared just in case
 +
 +   P5DIR |= BIT0;
 +
 +   _EINT();
 + }
 +
 + void main(void)
 + {
 +   volatile unsigned int i;
 +   volatile unsigned char x;
 +   WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer
 +   P6DIR |= 0x01;
 +   initUart();
 +   init7021_n();
 +   init_txrx_interrupt();
 +
 +   // // _BIS_SR(LPM0_bits + GIE);                 // Enter LPM3 w/ interrupt
 +
 +   _EINT();
 + //   sending = 1;
 +    step = 10;
 +    __delay_cycles(1000000);
 +
 + //   while(1) {
 + //    for(i=0; i < 12;i++ ) {
 + //   ascii(_message[i]);
 + //    }
 + //   }
 +
 + while (1) {
 +   if (sending == 1) {
 +   UCTL0 &= ~CHAR;
 +
 +   InitI2C();
 +
 +   for(i=0; i < step-1;i++ ) {
 +   x= EEPROM_ByteWrite(i, message[i]);
 +   EEPROM_AckPolling();
 +   }
 +
 +   for(i=0; i < step-1;i++ ) {
 +   x = EEPROM_RandomRead(i);
 +   ascii(x);
 +   }
 +   step=0;
 +   sending=0;
 +
 +   //Re-Configuring the USART Module for UART or SPI Operation
 +   UCTL0 &= ~I2C; //Clear I2C, SYNC, and I2CEN (CLR.B  &U0CTL)
 +   UCTL0 &= ~SYNC;
 +   UCTL0 &= ~I2CEN;
 +
 +   UCTL0 |= SWRST;                          // Set SWRST (MOV.B  #SWRST,&U0CTL)
 +
 +   initUart();
 +   }
 +   }
 + }
 +
 + #pragma vector=USART0RX_VECTOR
 + __interrupt void usart0_rx (void)
 + {
 +
 +   while (!(IFG1 & UTXIFG0));                // USART1 TX buffer ready?
 +   TXBUF0 = RXBUF0;                          // RXBUF1 to TXBUF1
 +   message[step] = RXBUF0;
 +
 +   _EINT();
 +
 +   step++;
 +   if (RXBUF0 == 13)   // CR
 +   {
 +   //P6OUT ^= 0x01;
 +   sending = 1;
 +   }
 + }
 +
 + // Port 1 interrupt service routine
 + #pragma vector=PORT1_VECTOR
 + __interrupt void Port_1(void)
 + {
 + //P6OUT ^= BIT0; // Toggle LED at P6.0
 + //P5OUT ^= BIT0; // Toggle LED at P5.0
 +
 + if(_message[m] & (1<<i)) {
 + P5OUT |= BIT0;
 + } else {
 + P5OUT &= ~BIT0;
 + }
 +
 + i--;
 +
 + if (i < 0){i = 7;m++;};
 + if (m >= 12){m = 0; };
 +
 + P1IFG &= ~BIT2; // P1.2 IFG cleared
 + }
 +
 +
 +
 +##### Transfer Frames Format
 +
 +AX.25
 +
 +
 +할일
 +
 + - Callsign 받기
 +
 +
 +
 +##### I2C msp430 communication
 +
 +
 +master 
 +
 +led 6.0
 +button 6.1
 +
 + #include  <msp430x16x.h>
 + void delay (void);
 + char TXData = 0;
 +
 + void main (void)
 + {
 +   WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
 +
 +   P3SEL |= 0x0A;                            // Select I2C pins
 +   U0CTL |= I2C + SYNC;                      // Recommended init procedure
 +   U0CTL &= ~I2CEN;                          // Recommended init procedure
 +   I2CTCTL |= I2CSSEL1 + I2CTRX;             // SMCLK, transmit
 +   I2CNDAT = 0x03;                           // Write Three bytes
 +   I2CSA = 0x0048;                           // Slave Address is 048h
 +   U0CTL |= I2CEN;                           // Enable I2C
 +
 +   U0CTL |= MST;                             // Master mode
 +   I2CTCTL |= I2CSTT + I2CSTP;               // Initiate transfer
 +   while ((I2CIFG & TXRDYIFG) == 0);         // Wait for transmitter to be ready
 +   I2CDRB = TXData;                          // Load  I2CDRB
 +   while ((I2CIFG & TXRDYIFG) == 0);         // Wait for transmitter to be ready
 +   I2CDRB = TXData;                          // Load  I2CDRB
 +   while ((I2CIFG & TXRDYIFG) == 0);         // Wait for transmitter to be ready
 +
 +   while(1)
 +   {
 +
 +   if((P6IN & BIT1) == 0) { // LOW?
 +   I2CDRB = 1;
 +   P6OUT |= BIT0;
 +   }
 +    }
 + }
 +
 +
 +slave
 +
 + #include  <msp430x16x.h>
 +
 + char RXData = 0;
 +
 + void main (void)
 + {
 +   WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
 +   P6DIR |= BIT0;
 +   P6OUT &= ~BIT0;
 +
 +   P3SEL |= 0x0A;                            // Select I2C pins
 +   U0CTL |= I2C + SYNC;                      // Recommended init procedure
 +   U0CTL &= ~I2CEN;                          // Recommended init procedure
 +   I2CTCTL |= I2CSSEL1;                      // SMCLK
 +   I2COA = 0x0048;                           // Own Address is 048h
 +   I2CIE = RXRDYIE;                          // Enable RXRDYIFG interrupt
 +   U0CTL |= I2CEN;                           // Enable I2C
 +
 +   _BIS_SR(LPM0_bits + GIE);                 // Enter LPM0 w/ interrupt
 +   while(1){
 +   if (RXData !=0)
 +   P6OUT |= BIT0;
 +   else
 +   P6OUT &= ~BIT0;
 +   }
 + }
 +
 +
 + // Common ISR for I2C Module
 + #pragma vector=USART0TX_VECTOR
 + __interrupt void I2C_ISR(void)
 + {
 + switch( I2CIV )
 + {
 +    case  2: break;                          // Arbitration lost
 +    case  4: break;                          // No Acknowledge
 +    case  6: break;                          // Own Address
 +    case  8: break;                          // Register Access Ready
 +    case 10:                                 // Receive Ready
 +       RXData = I2CDRB;                      // RX data
 +      _BIC_SR_IRQ(CPUOFF);                   // Clear LPM0
 +      break;
 +    case 12:  break;                         // Transmit Ready
 +    case 14: break;                          // General Call
 +    case 16: break;                          // Start Condition
 + }
 + }
 +
 +
 +
 +
 +
 +#### msp430 blink assembly
 +
 +blink 
 +
 + ;*******************************************************************************
 + ;   MSP430x1xx Demo - Software Toggle P1.0
 + ;
 + ;   Description; Toggle P1.0 by xor'ing P0.1 inside of a software loop.
 + ;   ACLK = n/a, MCLK = SMCLK = default DCO ~ 800k
 + ;
 + ;                MSP430x1xx
 + ;             -----------------
 + ;         /|\|              XIN|-
 + ;          | |                 |
 + ;          --|RST          XOUT|-
 + ;            |                 |
 + ;            |             P6.0|-->LED
 + ;
 + ;   M.Buccini
 + ;   Texas Instruments, Inc
 + ;   September 2004
 + ;   Built with CCE for MSP430 Version: 1.00
 + ;*******************************************************************************
 +             .cdecls C,LIST,"msp430x16x.h"  ; Include device header file
 +
 + ;-------------------------------------------------------------------------------
 +             .text                           ; Progam Start
 + ;-------------------------------------------------------------------------------
 + RESET       mov.w   #300h,SP                ; Initialize 'x1121 stackpointer
 + StopWDT     mov.w   #WDTPW+WDTHOLD,&WDTCTL  ; Stop WDT
 + SetupP1     bis.b   #001h,&P6DIR            ; P1.0 output
 +                                             ;
 + Mainloop    xor.b   #001h,&P6OUT            ; Toggle P6.0
 + Wait        mov.w   #050000,R15             ; Delay to R15
 + L1          dec.w   R15                     ; Decrement R15
 +             jnz     L1                      ; Delay over?
 +             jmp     Mainloop                ; Again
 +                                             ;
 + ;-------------------------------------------------------------------------------
 + ;           Interrupt Vectors
 + ;-------------------------------------------------------------------------------
 +             .sect   ".reset"                ; MSP430 RESET Vector
 +             .short  RESET                   ;
 +
 +             .end
 +
 +
 +
 +
 +
  </markdown>  </markdown>
ossicubesat.1336287371.txt.gz · Last modified: 2018/07/18 14:09 (external edit)