消えゆく世界と流れる未来に最後の灯を since 2006/4/3
#include <msp430.h>
#include <msp430g2553.h>
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
DCOCTL = 0; // Select lowest DCOx and MODx settings
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
P1SEL |= BIT1+BIT5+BIT6+BIT7;
P1SEL2 |= BIT1+BIT5+BIT6+BIT7; // Enable RXD (P1.1) SPI (P1.5-1.7)
UCA0CTL1 |= UCSSEL_2; // USCI clock source = SMCLK = 1MHz at default
UCA0BR0 = 0x68; // Frequency divider for UART
UCA0BR1 = 0x00; // 9600Hz is needed, but 1MHz/104=9615Hz is set
UCA0MCTL = UCBRS0; // UCBRSx=1 UCA0CTL1 |= UCSSEL_2; // USCI clock source = SMCLK = 1MHz at default
UCB0CTL0 |= UCMST;
UCB0CTL1 |= UCSSEL_2; // USCI clock source = SMCLK = 1MHz at default
UCB0BR0 = 0x68; // Frequency divider for SPI
UCB0BR1 = 0x00; // 9600Hz is needed, but 1MHz/104=9615Hz is set
UCB0CTL1 &= ~UCSWRST;
UCA0CTL1 &= ~UCSWRST; // Initialize UCSI state machine
UC0IE |= UCA0RXIE; // USCI_A0 RX interrupt
__bis_SR_register(CPUOFF + GIE);
}
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void) {
char a;
if (IFG2 & UCA0RXIFG) {
a = UCA0RXBUF;
UCB0TXBUF = a;
}
}
#include <msp430.h>
#include <msp430g2553.h>
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
DCOCTL = 0; // Select lowest DCOx and MODx settings
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
P1SEL |= BIT2+BIT5+BIT6+BIT7;
P1SEL2 |= BIT2+BIT5+BIT6+BIT7; // Enable TXD (P1.2) SPI (P1.5-1.7)
UCA0CTL1 |= UCSSEL_2; // USCI clock source = SMCLK = 1MHz at default
UCA0BR0 = 0x68; // Frequency divider for UART
UCA0BR1 = 0x00; // 9600Hz is needed, but 1MHz/104=9615Hz is set
UCA0MCTL = UCBRS0; // UCBRSx=1 UCA0CTL1 |= UCSSEL_2; // USCI clock source = SMCLK = 1MHz at default
UCB0CTL1 |= UCSSEL_2; // USCI clock source = SMCLK = 1MHz at default
UCB0BR0 = 0x68; // Frequency divider for SPI
UCB0BR1 = 0x00; // 9600Hz is needed, but 1MHz/104=9615Hz is set
UCB0CTL1 &= ~UCSWRST;
UCA0CTL1 &= ~UCSWRST; // Initialize UCSI state machine
UC0IE |= UCB0RXIE; // USCI_A0 RX interrupt
__bis_SR_register(CPUOFF + GIE);
}
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void) {
char a;
if (IFG2 & UCB0RXIFG) {
a = UCB0RXBUF;
UCA0TXBUF = a;
}
}
見りゃ分かると思うけど、ほとんどコピペ。