ossicubesat
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| ossicubesat [2012/05/13 18:54] – donghee | ossicubesat [2018/07/18 14:10] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1598: | Line 1598: | ||
| - Callsign 받기 | - Callsign 받기 | ||
| + | |||
| + | |||
| + | |||
| + | ##### I2C msp430 communication | ||
| + | |||
| + | |||
| + | master | ||
| + | |||
| + | led 6.0 | ||
| + | button 6.1 | ||
| + | |||
| + | # | ||
| + | void delay (void); | ||
| + | char TXData = 0; | ||
| + | |||
| + | void main (void) | ||
| + | { | ||
| + | WDTCTL = WDTPW + WDTHOLD; | ||
| + | |||
| + | P3SEL |= 0x0A; // Select I2C pins | ||
| + | U0CTL |= I2C + SYNC; // Recommended init procedure | ||
| + | U0CTL &= ~I2CEN; | ||
| + | I2CTCTL |= I2CSSEL1 + I2CTRX; | ||
| + | I2CNDAT = 0x03; // Write Three bytes | ||
| + | I2CSA = 0x0048; | ||
| + | U0CTL |= I2CEN; | ||
| + | |||
| + | U0CTL |= MST; // Master mode | ||
| + | I2CTCTL |= I2CSTT + I2CSTP; | ||
| + | while ((I2CIFG & TXRDYIFG) == 0); // Wait for transmitter to be ready | ||
| + | I2CDRB = TXData; | ||
| + | while ((I2CIFG & TXRDYIFG) == 0); // Wait for transmitter to be ready | ||
| + | I2CDRB = TXData; | ||
| + | while ((I2CIFG & TXRDYIFG) == 0); // Wait for transmitter to be ready | ||
| + | |||
| + | while(1) | ||
| + | { | ||
| + | |||
| + | if((P6IN & BIT1) == 0) { // LOW? | ||
| + | I2CDRB = 1; | ||
| + | P6OUT |= BIT0; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | slave | ||
| + | |||
| + | # | ||
| + | |||
| + | char RXData = 0; | ||
| + | |||
| + | void main (void) | ||
| + | { | ||
| + | WDTCTL = WDTPW + WDTHOLD; | ||
| + | P6DIR |= BIT0; | ||
| + | P6OUT &= ~BIT0; | ||
| + | |||
| + | P3SEL |= 0x0A; // Select I2C pins | ||
| + | U0CTL |= I2C + SYNC; // Recommended init procedure | ||
| + | U0CTL &= ~I2CEN; | ||
| + | I2CTCTL |= I2CSSEL1; | ||
| + | I2COA = 0x0048; | ||
| + | I2CIE = RXRDYIE; | ||
| + | U0CTL |= I2CEN; | ||
| + | |||
| + | _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 10: // Receive Ready | ||
| + | RXData = I2CDRB; | ||
| + | | ||
| + | | ||
| + | case 12: break; | ||
| + | case 14: break; | ||
| + | case 16: break; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | #### msp430 blink assembly | ||
| + | |||
| + | blink | ||
| + | |||
| + | ; | ||
| + | ; | ||
| + | ; | ||
| + | ; | ||
| + | ; ACLK = n/a, MCLK = SMCLK = default DCO ~ 800k | ||
| + | ; | ||
| + | ; MSP430x1xx | ||
| + | ; | ||
| + | ; / | ||
| + | ; | | | | ||
| + | ; --|RST | ||
| + | ; | | | ||
| + | ; | | ||
| + | ; | ||
| + | ; | ||
| + | ; Texas Instruments, | ||
| + | ; | ||
| + | ; Built with CCE for MSP430 Version: 1.00 | ||
| + | ; | ||
| + | .cdecls C, | ||
| + | |||
| + | ; | ||
| + | .text ; Progam Start | ||
| + | ; | ||
| + | RESET | ||
| + | StopWDT | ||
| + | SetupP1 | ||
| + | ; | ||
| + | Mainloop | ||
| + | Wait mov.w # | ||
| + | L1 dec.w | ||
| + | jnz | ||
| + | jmp | ||
| + | ; | ||
| + | ; | ||
| + | ; | ||
| + | ; | ||
| + | .sect " | ||
| + | .short | ||
| + | |||
| + | .end | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| </ | </ | ||
ossicubesat.1336935251.txt.gz · Last modified: 2018/07/18 14:09 (external edit)