4
\$\begingroup\$

printf() to console through Spy-Bi-Wire should be supported in the TI Code Composer Studio. Found this page, which explains how to enable printf(). But I can't seem to make it work. The program execution simply hangs, when it gets to printf().

My setup consists of:

To try to enable the printf(), I’ve changed these settings in Project->Properties:

  • Console I/O (CIO) enabled
  • Stack size 768, heap size 1024. (Also tried 300 and 400, respectively.)
  • printf() support set to minimal
/*
 * ======== Standard MSP430 includes ========
 */
#include <msp430.h>
#include <stdio.h>

/*
 * ======== Grace related includes ========
 */
#include <ti/mcu/msp430/Grace.h>

/*
 *  ======== main ========
 */
int main(void)
{
    Grace_init();                   // Activate Grace-generated configuration

    while (1)
    {
        P1OUT |= BIT0;
        __delay_cycles(100000);
        P1OUT &= ~ (BIT0);
        __delay_cycles(100000);

        printf("*\n");    // hangs here
    }

    return (0);
}

The problem is that program execution hangs, when it gets to printf().

In the disassembly view, the code hangs at this line

000004  3FFF  JMP  (0x0004)

Is this an endless jump?

At one point, I though that there's a problem with my CCStudio installation. Initially, I've installed 5.3 on top of 4. I've installed CCStudio 5.3 on another computer (virgin one). I'm seeing exactly the same problem.

Come to think of it, I'm using the same FET430. May be, the problem is in my FET430 or it's firmware.

What am I missing? What could go wrong?
Have anyone else had problems like this?
Is this something that works with 4-wire JTAG, but doesn't work with Spy-Bi-Wire?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Here's a more updated wiki page regarding printf support: processors.wiki.ti.com/index.php/… I don't know why it is not working for you, but have you tried without using Grace? \$\endgroup\$ Commented Feb 28, 2013 at 19:11
  • \$\begingroup\$ Just a though: printf("*\n\r"); -- or \r\n \$\endgroup\$
    – vermaete
    Commented Feb 28, 2013 at 19:16

1 Answer 1

3
\$\begingroup\$

It sounds like a memory allocation problem, while I haven't used the MSP430 series a lot I see the MSP430FR5739 only has 1K of SRAM so a few settings you've tried don't make a lot of sense. For a start you should try reading the memory map and see how much room the static variables take so you can calculate how much of the 1K is left for the stack and heap also also read the documentation for printf to see how much of each it requires.

0x3FFF corresponds to a relative jmp -1 so in other words an infinite loop. I'm not sure with CCStudio in particular but many compilers fill unused memory with such an instruction. That means if the code jumps to a location containing no code execution stops rather than continuing potentially causing further problems.

Personally I never use printf on small microcontrollers, you are much better off starting with simple character output routines like putchar and puts. Then if I you need numeric output for example roll your own minimal routines to do what you require. The printf library can be quite large even in compact variants due to the wide number of formats it supports even though you're probably not using them.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.