EmbeddedRelated.com
Forums

Printf statement used on IAR compiler / MSP430 processor

Started by JS October 4, 2007
On 2007-10-05, JS <xyz@yahoo.com> wrote:

>> printf isn't too useful On the ones with 2K of codespace and >> 128-256 bytes of RAM. On ones with 60KB of codespace and 4K of >> RAM, it can be very useful. Since I rarely have a spare HW >> UART, I ususally bit-bang the printf output. I also use a >> carefully optimized, custom printf function that's only a >> couple KB of code and requires very little RAM.
> One of the basic example which I think it is quite useful is > for instance if you want to find out what the output pins > of PORT1 are at certain point in the program --- that way > you don't have to physically put the scope probe on them. > > void read_port_value(void) > { > uchar value; > value = PORT1; //read CPU port1 > printf(" Display Port1 value = %X", value); //Display port1 in hex > on PC terminal > }
Which is fine if you've got the spare RAM and ROM for printf. On some of my projects I've only got a few bytes of extra RAM, and printf just can't run with that little available RAM for it to use. -- Grant Edwards grante Yow! In Newark the at laundromats are open 24 visi.com hours a day!
On Oct 4, 8:45 pm, "JS" <x...@yahoo.com> wrote:
> One of the basic example which I think it is quite useful is > for instance if you want to find out what the output pins > of PORT1 are at certain point in the program --- that way
It really depends if you want to pull in all that extra baggage. Converting an 8-bit value to ASCII hex is a few lines of C or assembler, and it doesn't require any RAM [on most architectures I can think of]; it can be done entirely in registers.