MSP430

MSP430, CCS, UART, printf 구현

CoyoteUgly 2018. 9. 6. 20:10

MSP430, CCS, UART, printf 구현



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. 소스 설명

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

1. support channel
 - USCI_A0
    - P2.1 : UCA0RXD
    - P2.0 : UCA0TXD  
 - USCI_A1
    - msp430fr6989 development kit backchannel (uart)
    - P3.5 : UCA1RXD
    - P3.4 : UCA1TXD
    
2. support option
 - USCI_Ax, CLOCK_1M,  BR_9600
 - (XXX) USCI_Ax, CLOCK_1M,  BR_115200
 - USCI_Ax, CLOCK_8M,  BR_9600
 - USCI_Ax, CLOCK_8M,  BR_115200
 - USCI_Ax, CLOCK_16M, BR_9600
 - USCI_Ax, CLOCK_16M, BR_115200

정수 출력 시에 (long int) 를 꼭 붙여 주세요. 안 그러면 값이 이상하게 나옵니다.

    myprintf("%s\r\n", ptr);
    myprintf("printf test\r\n");
    myprintf("%s is null pointer\r\n", np);
    myprintf("%d = 5\r\n", (long int)i);
    myprintf("%d = - max int\r\n", mi);
    myprintf("Long int 123456789 print out is %u", (long int)123456789);
    myprintf("\r\nmi in hex is %x\r\n", (long int)mi);
    myprintf("bs in dec is %u\r\n", (long int)bs);
    myprintf("char %c = 'a'\r\n", 'a');
    myprintf("hex %x = ff\r\n", (long int)0xff);
    myprintf("hex %02x = 00\r\n", (long int)0);
    myprintf("signed %d = unsigned %u = hex %x\r\n", (long int)-32767, (long int)-32767, (long int)-32767);
    myprintf("signed %d = unsigned %u = hex %x\r\n", (long int)-3, (long int)-3, (long int)-3);
    myprintf("%d %s(s)%", (long int)0, "message");
    myprintf("\r\n");
    myprintf("%d %s(s) with %%\r\n", (long int)0, "message");
    myprintf("justif: \"%-10s\"\r\n", "left");
    myprintf("justif: \"%10s\"\r\n", "right");
    myprintf(" 3: %04d zero padded\r\n", (long int)3);
    myprintf(" 3: %-4d left justif.\r\n", (long int)3);
    myprintf(" 3: %4d right justif.\r\n", (long int)3);
    myprintf("-3: %04d zero padded\r\n", (long int)-3);
    myprintf("-3: %-4d left justif.\r\n", (long int)-3);
    myprintf("-3: %4d right justif.\r\n\r\n\r\n", (long int)-3); 


2. 소스


3. 결과


'MSP430' 카테고리의 다른 글

MSP430, CCS, I2C, PCF8563  (0) 2018.09.06
MSP430, CCS, RTC, Internal Register  (0) 2018.09.06
MSP430, CCS, LCDMEM  (0) 2018.09.06
MSP430, CCS, ADC, rotation_sensor  (0) 2018.09.05
MSP430, CCS, SPI, at45dbxx data flash  (0) 2018.09.05