MSP430

MSP430, CCS, USCI_A0, UartEcho

CoyoteUgly 2018. 9. 3. 21:50

MSP430, CCS, USCI_A0, UartEcho



msp430.h 를 사용하는 소스입니다.


Did you have a look at the example codes for the MCU that is provided by TI for almost every processor?


www.ti.com/lit/zip/slac536


The following examples show how to set up the clocks:

msp430fr59xx_cs_01.c       Configure MCLK for 8MHz operation
msp430fr59xx_cs_02.c       Configure MCLK for 16MHz operation
msp430fr59xx_cs_03.c       Output 32768Hz crystal on XT1 and observe failsafe
msp430fr59xx_cs_04.c       ACLK = XT1 = 32768Hz, SMCLK= XT2 = 8MHz, MCLK = DCO
msp430fr59xx_cs_05.c       Using LFXT in bypass mode, failsafe operation shown


0. 참고 사항



출처: http://coyoteugly.tistory.com/188 [마이콤 개발자를 위한 여행]

0. 참고 사항


1. HW 구성


2. 소스 설명

1. P1.0 LED

2. use USCI_A0

- P2.1 : UCA0RXD

- P2.0 : UCA0TXD

- BaudRate : 115200


full 소스는 아래 github를 통해 확인하세요.


void initUART()
{
    // Configure USCI_A0 for UART mode
    UCA0CTLW0 = UCSWRST;                      // Put eUSCI in reset

    UCA0CTLW0 |= UCSSEL__SMCLK;               // CLK = SMCLK

    // Baud Rate Setting
    // Use Table 30-5 in Family User Guide
    UCA0BR0 = 8;
    UCA0BR1 = 0;
    UCA0MCTLW |= UCOS16 | UCBRF_10 | 0xF700;   //0xF700 is UCBRSx = 0xF7

    UCA0CTLW0 &= ~UCSWRST;                    // Initialize eUSCI
    UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt
}

void initGPIO()
{

    // Configure UART
    P2SEL0 |= BIT0 | BIT1;                    // USCI_A0 UART operation
    P2SEL1 &= ~(BIT0 | BIT1);

    // Configure PJ.5 PJ.4 for external crystal oscillator
    PJSEL0 |= BIT4 | BIT5;                    // For XT1


}

#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
    switch(__even_in_range(UCA0IV, USCI_UART_UCTXCPTIFG))
    {
    case USCI_NONE: break;
    case USCI_UART_UCRXIFG:
        LED0_OUT ^= LED0_PIN;

        while(!(UCA0IFG & UCTXIFG));
        UCA0TXBUF = UCA0RXBUF;
        __no_operation();
        break;
    case USCI_UART_UCTXIFG: break;
    case USCI_UART_UCSTTIFG: break;
    case USCI_UART_UCTXCPTIFG: break;
    }
}


3. 소스


4. 결과



'MSP430' 카테고리의 다른 글

MSP430, CCS, ADC, rotation_sensor  (0) 2018.09.05
MSP430, CCS, SPI, at45dbxx data flash  (0) 2018.09.05
MSP430, MSP430FR6x8x_Code_Examples  (0) 2018.09.03
MSP430, CCS, 16MHz Clock  (0) 2018.09.03
MSP430, CCS, 8MHz Clock  (0) 2018.09.03