Hi all,
I'm current doing some recreational testing and debugging -- I have an eZ430-RF2500 chip with the MSP430F2274 on-board.
Right now, the most I've done at this point was a simple interrupt-driven piece of code that switches the LEDs when the pushbutton is pressed.
I'd like to use standard output with the board, which I've heard is possible, but I haven't gotten it working. I've currently included "stdio.h" and have a single printf() statement in the main of the program. I've also tried it with the printf() in the interrupt itself.
When I run the program on the chip, everything still works fine with the printf() and all there -- just the printf() doesn't ever seem to trigger. Nothing in the console, etc.
So is it possible to get this to work...? I figure it should be. Just not sure why it's not working.
Thanks very much.
Hi,
have you tried opening a CIO console or the terminal plug-in? What version of CCS do you use? What printf settings do you have? Do you have full printf support enabled? Did you increase your stack or heap size?
Best Regards,
Lisa
Hi Lisa,
Thanks for the speedy response. I can't really easily find anything about most of those things in CCS (or documents) after having searched a lot prior to this.
Pardon my lack of knowledge, as I've tried searching quite a few documents already to no avail. I've done this kind of programming before, and I know what the things you're speaking of are (e.g. stacks and heaps) and how they relate to the hardware. But it's the first time I'm using an IDE for this, and I've never made such adjustments before. So I'm not entirely where to find them or how to figure such things out.
So if you could point me anywhere in the IDE or in a document, that'd be greatly appreciated.
Thank you again for the response.
Hi Duane,
Have a look at these two wiki topics and please keep us informed if they get you up and running
http://processors.wiki.ti.com/index.php/Printf_support_for_MSP430_CCSTUDIO_compiler
http://processors.wiki.ti.com/index.php/How_to_install_the_terminal_plugin_in_CCSv5
Best Regards,Lisa
Lisa,
:EDIT:
This is an edit to the below information. The datasheet states that this MSP430F2274 has 1 KB of RAM. So 80 for the stack and 92 for the heap should not be anywhere near the limit. But it appears to still give me error when I got beyond the 80 + 92 = 172 limit...
Thanks again for the response. When attempting to follow the wiki, I have received the following error:
When looking into the error for the size of the program, it suggests to do one of three things: 1) decrease the heap size I allocated; 2) optimize the code more; and 3) choose minimal printf().
So the wiki showed an MSP430 getting allocated 320 bytes of memory for the heap and 160 for the stack. Currently my program has 80 and 80 for both (it was the default in the project I'm building off of) and it's a small program with next to nothing really happening.
When I choose to disable printf() completely, then I keep decreasing the heap size allocated -- the highest I can allocate to the heap is 92 bytes before the above error shows. And that is with the " " blank option chosen for printf() support.
If I choose Full printf() support after that, then the project still builds, but of course nothing happens. And well I figured it would do nothing anyway as the Wiki claims it needs 300 bytes of heap for full support.
Similarly, minimal support does nothing either.
So my last attempt was to check optimization, where if I set Optimization Level 4, it ran some extra processes to compile the code "better" -- but again, nothing happened with printf(). And if I attempt to increase the heap size with Optimization, I still get the same error -- but I guess that's simply because the MSP430 doesn't have enough memory for it?
The same occurs if I increase the stack. So right now I have 80 for the stack, 92 for the heap in the Linker settings. If I increase either, I get the error -- so 172 bytes total? I'm just not sure how the one in the wiki has 160 + 320 = 480 bytes overall unless it's a completely different model of MSP430 with much more memory.
So I'm supposing that I just can't use printf() on this...
one thing that might be a good idea here is to check your compiler version. Could you please go to Window->Preferences->Code COmposer Studio->Build->COde Generation Tools and see what version(s) of the MSP430 compiler you have? Which are you using for this project. There have been some known issues with printf so it may be I should send you a newer version offline.
I went to the preferences and found the following. "Tool Discovery Path" is:
"Discovered Tools" has "MSP430", underneath of which there are:
If I hit Refresh next to the list of tools, the list remains the same.
Thanks.
ok, let me send you a version offline to try with some specific bug fixes. Please look for a friend conversation request. I can then follow that with the instructions for you.
Try using puts instead of printf; puts has much lower memory footprint, so it should be easier to verify that CIO is working.
See also http://processors.wiki.ti.com/index.php/Tips_for_using_printf
I installed the new compiler version and chose to set it as the Compiler for my project.
Now that the Compiler is installed, the project will allow me to increase my Stack Size and Heap Size without throwing errors. Further, I'm able to set Full for printf() settings as well -- still no errors.
I uncommented including "stdio.h" -- still no errors.
However, the very last step -- when I uncommented printf() itself in my code, I got:
So the new compiler version removed the erroneous mistakes with CCS not letting me increase my Stack and Heap space available. But the error still appears for printf(). The above error showed with 80 bytes of stack space, 380 bytes of heap space, and almost all of the previous functionality of my code commented. Note: It doesn't work even when I increase stack size, decrease either, etc etc. I tried 500 Stack Size (as I saw in the Wiki that the stack should be 400 or so high) and 380 Heap size. That's under the 1 KB of RAM needed for the Chip and almost everything in my program was not there except for the essentials. I figured this may be more than the 1KB anyway but I've kept decreasing each after to see the effects. The error still goes.
And not that it gives much more information, but I just realized that when I double-click on the #10099-D error (I only tried clicking on the other error that comes with it before), it takes me to the linker ".cmd" file, and the error appears on the line " .cio : {} > RAM /* C I/O BUFFER */", so of course it's only the CIO buffer.
---
Also to Archaeologist,
I will try puts and see what happens.
Edit: Puts does nothing. Even with breakpoints, I get no output.
let me give a few things a run through in the morning for you, but in the mean time have you
-enabled CIO output
- opened a CIO console
Yes, I have ensured that I have done both. And not viewing a console would not cause a size error to show when the compiler runs.
Thanks again.
I tried specifically on an F2274 and see the same thing. I suspect you might be out of luck as this seems to be an issue that the device does not have enough memory to support printf. Unfortunately printf is pretty heavy.
You can have a look at these wikis just in case there might have been something missed here ... but the device does not seem to like the min required stack/heap size unfortunately.
http://processors.wiki.ti.com/index.php/Tips_for_using_printf
Hope this helps confirm the suspicions.
LIsa
Try the following program. It's nearly as small as you can get and still have CIO. It does not use any heap, and needs only about 20 bytes of stack, so you can use -heap 0 and -stack 50. This should trivially fit on a MSP430F2274 without danger of stack overflow.
#include <stdio.h> #include <string.h> #include <file.h> int main() { const char hello[] = "Hello, world\n"; return write(1, hello, sizeof hello); }
Archaeologist,
Thanks very much for that program. That worked just fine with output.
I will just look at the function closer and see what's going on in relation to my program.
Hi, Im trying to sink into programming and I have some strange behavious with CCS and msp430g2553 (launchpad).
Im trying to printf test code (via JTAG to console - only for test) some string , but with CCS 5.2 I cant compile code because of 4 errors:
#10010 errors encountered during linking; "LPad.out" not built
#10099-D</a> program will not fit into available memory. run placement with alignment fails for section ".stack" size 0x50 . Available memory ranges:
#10099-D</a> program will not fit into available memory. run placement with alignment fails for section ".sysmem" size 0x50 . Available memory ranges:
#10099-D</a> program will not fit into available memory. run placement with alignment fails for section "DATA_GROUP" size 0xf6 . Available memory ranges:
I find (above) problem with heap or non available/less memory , so I increase heap size to 300,400,500 but still same error. I ascribed error to low hw resources on 2553, but same code WORK with IAR 5.40 in FULL printf model with size :
6 652 bytes of CODE memory 80 bytes of DATA memory (+ 15 absolute ) 34 bytes of CONST memory
So whats the problem with CCS, when HW resources on chip are sufficient (consideration based on working code from IAR). Thanks ;)
#include "msp430g2553.h"#include "stdio.h"
void sendChar(unsigned char ch){while(!(IFG2&UCA0TXIFG));UCA0TXBUF=ch;}
void sendStr(const char *string){while(!((*string) == '\0')){sendChar(*string);string++;}}
unsigned int fcia(unsigned int x) {unsigned int a=34123;unsigned int b=1;unsigned int *ptr;ptr=&b;b=x+a;UCA0TXBUF=*ptr;return b;}
void main(void) {unsigned int c;WDTCTL = WDTPW + WDTHOLD; // Stop WDTBCSCTL1 = CALBC1_1MHZ; // 86 // Set DCODCOCTL = CALDCO_1MHZ; // D2P1SEL = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXDP1SEL2 = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXDUCA0CTL1 |= UCSSEL_2; // SMCLKUCA0BR0 = 104; // 1MHz 9600UCA0BR1 = 0; // 1MHz 9600UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
c=fcia(2); __delay_cycles(1);printf("numbe %c",c); //!!!!!!!!!!!!!!§HERE PRINTF__delay_cycles(1);__bis_SR_register(GIE); // Enter LPM0, interrupts enabled}