Jump to content
Omer

printf() on CCSv5 debugger

Recommended Posts

Hi,

I'm using CCS5 with a MSP430F247. I need outputs to help with debugging and monitoring.

I set up the 'Variant' field. Enabled CI\O support and increased stack and heap sizes.

My code is as follows: 

 

#include <msp430.h>
#include <stdio.h>

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

    printf("a\n");

    return 0;
}

 

This is just a test project so I could rely on the console in the future.

 

When I run this, the character 'a' gets printed to the CIO console, but I get the message:

 

"MSP430: Trouble Writing Memory Block at 0x1240 on Page 0 of Length 0xa: Could not write device memory"

 

on the project console and the debugger gets stuck at function C$$IO$$(). The memory address 0x1240 points to the beginning of _CIOBUF_.

 

Even though it states "Could not write device memory", I can see in the Memory Browser that the memory at that address is changed, and I also have been able to write to that address manually with pointers.

 

I also tried some workaround methods, like using tinyPrintf() or another putc() but they didn't even write to the console.

 

I would highly appreciate ideas as to how to print safely to the console.

Thanks.

Share this post


Link to post
Share on other sites

printf (and stdio) are expensive, this library alone could cause you to run out of memory. Try using iostream C++ library, since this is a template class it will only link those parts you actually use. It might save a lot of code space.

Share this post


Link to post
Share on other sites

printf also uses a precious hardware breakpoint, and it is blocking.  I'm guessing there is some configuration conflict in your setup, or possibly you just have too many hardware breakpoints set.  I seem to remember getting errors like this when breakpoints are exhausted and trying to step through code.

 

If you want to free-up a hardware breakpoint, you will need to write your own printf.

 

I should also mention that I do not recommend using software breakpoints.  If you are using the launchpad with the SBW ICD, you don't have software breakpoints anyway, so nothing to worry about in that case.

Share this post


Link to post
Share on other sites

Why is printf using a breakpoint?! Does it not use the usual serial interface for the printing?

 

Software breakpoints can be emulated on the launchpad using single stepping, but this is slow! In the sense of your CPU clock is reduced to a few hertz at most.

Share this post


Link to post
Share on other sites

It uses CIO by default - part of the streams system supported by CCS. Horrible bloated crap.

 

It is possible to use CIO without using TI's RTS library.

 

Printing via CIO: http://forum.43oh.com/topic/2354-printing-to-the-ccs-debugger-console/

 

Get time via CIO: http://forum.43oh.com/topic/2356-get-host-time-using-ccs-debugger-cio/

Share this post


Link to post
Share on other sites

Yes, oPossum, I found your tiny printf and putc before I posted but couldn't get it to work. Seems I just didn't understand that I need to use cio_flush() for the putc() to set the cio breakpoint. It is now printing for me even without enabling cio in the project properties.

 

But it still gets stuck after printing, like before. I get the same error message in the console (albeit with another address pointing to the new _CIOBUF_) and a new editor tab that says:

No source available for "C$$IO$$() at C:\Users\Omer\CodeComposerWorkspace\Card2\Debug\Card2.out:{3} 0x81a8{4}"

(which is to be expected since I gather the program is stepping into an assembly funciton.)

 

I can then step over with the debugger step by step and finish the program run, but I don't understand why It gets stuck in the first place.

 

So it probably isn't the memory usage being to big, though of course a small printf() is always welcome.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...