Quantcast
Channel: MSP low-power microcontrollers
Viewing all articles
Browse latest Browse all 62309

Forum Post: printf support for CCSv6 - garbage on monitor

$
0
0
Hello, I am using the MSP-EXP430F5529 evaluation kit. I am also using CCS v6.2 i want to print a number of messages to the UART RXD line for debug and general system information. I have followed the instructions on the IT wiki page. Printf_support_for_MSP430_ CCSTUDIO _compiler. ( I would love to post a link but this apparently cannot be done on this forum...weird) The issue I have is that I see garbage on my putty monitor. I have configured the putty to the right com port and set the baud rate to 1200. I double check the baud rate using a calculator on ti so I am confident that UCA1BRO = 27 and UCA1BR1 = 0. The data coming out is total garbage, but there is data. Here is my code...again taken straight from the ti website. the only thing I changed was the UCA1 UART RXD and TXD port to reflect the MSP-EXP430F5529LP evaluation board. ______ #include #include #include #include #define UART_PRINTF #ifdef UART_PRINTF //setup to have print statements on serial RFD port int fputc(int _c, register FILE *_fp); //see processors.wiki.ti.com/.../Printf_support_for_MSP430_CCSTUDIO_compiler int fputs(const char *_ptr, register FILE *_fp); #endif void main(void){ unsigned int counter=0; WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer init_serialprint(); // chris - printf setup while(1) //Printf task { __bis_SR_register(LPM3_bits+GIE); // Enter LPM3, enable interrupts printf("Hello world %d!\r\n", counter++); } } init_serialprint() { //code copied from processors.wiki.ti.com/.../Printf_support_for_MSP430_CCSTUDIO_compiler // initialize clock module P1DIR |= 0x01; // P1.0 output UCSCTL3 |= SELREF__REFOCLK; UCSCTL4 |= SELA__REFOCLK; // initialize Timer_A module TA1CCTL0 = CCIE; // CCR0 interrupt enabled TA1CCR0 = 32768; TA1CTL = TASSEL__ACLK + MC__UP + TACLR; // ACLK, up mode, clear TAR #ifdef UART_PRINTF // initialize USCI module P4SEL |= BIT4 + BIT5; // P4.4,5 = USCI_A1 TXD/RXD Changed to accommodate MSP-EXP430F5529LP UCA1CTL1 |= UCSWRST; // **Put state machine in reset** UCA1CTL1 |= UCSSEL__ACLK; // AMCLK UCA1BR0 = 27; // 32,768kHz 1200 (see User's Guide) UCA1BR1 = 0; // 32,768kHz 1200 UCA1MCTL = UCBRS_2; // 32,768kHz 1200 UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine** #endif } // Timer A0 interrupt service routine #pragma vector=TIMER1_A0_VECTOR __interrupt void TIMER1_A0_ISR(void) { P1OUT ^= 0x01; // Toggle P1.0 __bic_SR_register_on_exit(LPM3_bits); } #ifdef UART_PRINTF int fputc(int _c, register FILE *_fp) { while(!(UCA1IFG&UCTXIFG)); UCA1TXBUF = (unsigned char) _c; return((unsigned char)_c); } int fputs(const char *_ptr, register FILE *_fp) { unsigned int i, len; len = strlen(_ptr); for(i=0 ; i<len ; i++) { while(!(UCA1IFG&UCTXIFG)); UCA1TXBUF = (unsigned char) _ptr[i]; } return len; } #endif

Viewing all articles
Browse latest Browse all 62309

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>