This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/MSP430F6736: printf support-output display

Part Number: MSP430F6736
Other Parts Discussed in Thread: CCSTUDIO

Tool/software: Code Composer Studio

I referred to this website: 

I wanted to print my output on the console so I referred to this website. But I couldn't find the printf compiler support setting under the "library function assumption" option.

I couldn't even find a "MSP430 linker" option in the properties.

What do I need to do in order to solve this issue?

My ultimate goal is to display the output values on the console.

Thank you.

  • Keval,

    I will answer the easy part first.  You are looking at the build options for a specific file (main.c) and not the project so you will not see linker options.  To see the options for the project select the project in Project Explorer and then right click and select properties.

    As far as the "Library Function Assumptions" section being blank I see the same.  I am not sure what is going on there but it certainly looks like an issue.  You can change the option in another way.

    Go to the properties for the project.  Select the MSP430 Compiler node in the tree on the left.

    Then click on the Edit Flags button.  This will allow you to edit the options manually.  In general the option --printf_support=minimal is set for MSP430.

    I would be surprised if that option was not already set as we set it by default when creating a new project.

    Have you added printf's to your code and having issues getting it to work?

    If you go to Project -> New CCS Project

    Choose your device

    Select the Hello world template

    Does that work?

    I suspect that you need to increase your heap size.

    Regards,

    John

  • Yes, I have used printf commands in my program but I am not getting values displayed on the console.
    I tried the "Hello World" template but even that didn't work.
    I tried changing the printf support to full from minimal, but even then I was not able to get the output displayed.
  • I will see if I can track down an MSP430F673x device. I have tried out the template on other MSP430s and it works fine.
  • Printf support would be set to minimal by default in the hello world template.

    I have not be able to locate an MSP430F673x device. If you set a breakpoint on the line that has the printf and run does it run to that line and halt?
  • The hello world template worked when I put a breakpoint on that line.
    However I am not able to print values of the ADC conversion result.

    I am using the following example code:

    #include <msp430.h>

    unsigned int ADC_Result;

    int main(void)
    {
    WDTCTL = WDTPW | WDTHOLD; // Stop WDT


    // Setup P1.2 for A0
    P1SEL |= BIT2; // Set P1.2 to non-IO
    __disable_interrupt(); // Disable interrupts; Port Map cnfg
    PMAPKEYID = PMAPKEY; // Enable access Port Mapping regs
    P1MAP2 = PM_ANALOG; // Enable A0
    PMAPKEYID = 0; // Disable access Port Mapping regs
    __enable_interrupt(); // Re-enable all interrupts
    P1DIR |= BIT0; // Set P1.0 to output direction
    P1OUT &= ~BIT0; // Clear P1.0

    // By default, REFMSTR=1 => REFCTL is used to configure the internal reference
    while (REFCTL0 & REFGENBUSY) ; // If ref generator busy, WAIT
    REFCTL0 |= REFVSEL_0 | REFON; // Select internal ref = 1.5V
    // Internal Reference ON
    // Setup ADC10
    ADC10CTL0 = ADC10SHT_2 | ADC10ON; // S&H=16 ADC clks, Enable ADC10
    ADC10CTL1 |= ADC10SHP; // ADCCLK = MODOSC; sampling timer
    ADC10CTL2 |= ADC10RES; // 10-bit conversion results
    ADC10IE |= ADC10IE0; // Enable ADC conv cmplete interrupt
    ADC10MCTL0 |= ADC10INCH_0 | ADC10SREF_1; // A0 ADC input select; Vref=1.5V

    // Configure TA0 to provide delay for reference settling ~75us
    TA0CCR0 = 80; // Delay to allow Ref to settle
    TA0CCTL0 |= CCIE; // Compare-mode interrupt.
    TA0CTL = TASSEL_2 | MC_1; // TACLK = SMCLK, Up mode.
    __bis_SR_register(LPM0_bits | GIE); // Enter LPM0 w/ interrupt
    TA0CCTL0 &= ~CCIE; // Disable timer interrupt

    while (1)
    {
    __delay_cycles(5000); // Delay between conversions

    ADC10CTL0 |= ADC10ENC | ADC10SC; // Sampling and conversion start

    __bis_SR_register(LPM0_bits | GIE); // Enter LPM0 w/ interrupt
    __no_operation(); // For debug only

    if (ADC_Result > 0x0100) // ADC10MEM = A0 > 0.5V?
    {
    P1OUT |= 0x01; // Clear P1.0 LED off
    printf("ADC result: %d\n",ADC_Result);
    }
    else
    {
    P1OUT &= ~0x01; // Set P1.0 LED on
    printf("ADC result: %d\n",ADC_Result);
    }
    }
    }

    // ADC10 interrupt service routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=ADC10_VECTOR
    __interrupt void ADC10_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(ADC10_VECTOR))) ADC10_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
    switch (__even_in_range(ADC10IV, 12))
    {
    case ADC10IV_NONE: break; // No interrupt
    case ADC10IV_ADC10OVIFG: break; // conversion result overflow
    case ADC10IV_ADC10TOVIFG: break; // conversion time overflow
    case ADC10IV_ADC10HIIFG: break; // ADC10HI
    case ADC10IV_ADC10LOIFG: break; // ADC10LO
    case ADC10IV_ADC10INIFG: break; // ADC10IN
    case ADC10IV_ADC10IFG: // ADC10
    ADC_Result = ADC10MEM0; // Store ADC10 channel 0 result
    __bic_SR_register_on_exit(LPM0_bits); // Exit LPM0 on return
    break;
    default: break;
    }
    }

    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=TIMER0_A0_VECTOR
    __interrupt void TA0_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(TIMER0_A0_VECTOR))) TA0_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
    TA0CTL = 0; // Reset TA0
    __bic_SR_register_on_exit(LPM0_bits); // Exit LPM0 on return
    }

    I want to print the conversion result of the ADC. I tried putting the printf command but it didn't work.
    I also put breakpoints on the two lines but no success.
    Could you help me out with this?

    Thank you.
  • I don't see #include <stdio.h>

    You need to have that.

    There is likely a warning in the build output about an implicit declaration of printf.
  • Thank you John for the help.

    Appreciate it.
  • No problem