Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24 - Page 3

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24


Quoted text here. Click to load it

LOL, that 2-3K makes a huge difference in products with 16K ROM or less and
there are very many of those.

Ian


Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24
Ian Bell schrieb:
Quoted text here. Click to load it

Optimization (writing a specialized function instead of using one from
the library is nothing but optimization) is done when necessary, and no
sooner. If your program with printf & Co. is 14k large and you target a
16k microcontroller, replacing standard functions with specialized code
will gain you absolutely nothing, but takes time, is error-prone, makes
your code larger and hurts maintainability.

Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24
Quoted text here. Click to load it

This is absolute rubbish. A simple function to put a character or two
out to a serial line will only be a few bytes long.

As printf has to use this functionality to address the hardware, and you
may want to re-direct printf, it is often made available in source form
in the library.  All you have to do is get the routine. Typically it is
only 4-5 lines of C.

Or you could do it yourself but if writing a SIMPLE function like this
"takes time, is error prone" should you be programming embedded systems
at all?

It will make you code 2-3K smaller and does NOT hurt maintainability at
all. IT gains you a lot as it makes the test outputting smaller and
faster so it distorts the memory map less than printf and changes the
time by a lot less.


--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
We've slightly trimmed the long signature. Click to see the full one.
Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24
Chris Hills schrieb:
Quoted text here. Click to load it
 >
Quoted text here. Click to load it

Appearantly we have a misunderstanding here. With printf I do not mean a
put-everything-on-stdout-C89-printf. Most libraries have a printf
variant that takes a function pointer argument for a putc function, or a
seperate function to set the printf target. Obviously you have to write
this one yourself.

The point I was trying to make is that it is useless to assemble a LCD
output by hand (formatting numbers, concatenating strings, padding with
spaces) when there is a function like printf that can do it all much
easiert, but may take a bit more space.

Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24
On Sunday, in article
Quoted text here. Click to load it

Creating a simple putc or put_string is easy.

Quoted text here. Click to load it

Creating a custom printf is MUCH better than using a library function
many applications do not need

        Floats
        scientific of exponential notation
        pointer printing
        long modifiers
        escape characters (form feed, line feed, bell)

Mnay only need single character or formatted strings with a byte or short
(signed/unsigned printing).

To create a custom printf is relatively easy and I have used a few, created
and expanded over time to have conditionally compilation for support required
(binary, octal, decimal, hex, pointer). Simple formatting for single
characters or strings as standard. Some of the conditional assembly for
16bit ranging from 400 bytes to 1000 bytes, depending on the target being
developed. Hence code reuse just like using a library, with known overhead.

--
Paul Carpenter          | snipped-for-privacy@pcserviceselectronics.co.uk
<http://www.pcserviceselectronics.co.uk/ PC Services
We've slightly trimmed the long signature. Click to see the full one.
Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24
On Sun, 16 Oct 2005 02:24:21 +0100 (BST),

Quoted text here. Click to load it

If the library sources are available, it should be easy to disable the
floats etc.

However, if the library sources are not available, but if the library
object files have been divided intelligently, e.g. the actual printf
function in printf.obj and the floating point printing routines in
print_float.obj, it should be possible to create dummy_float.c
containing e.g.

void print_float (double d.....)
{
    return ;
}

Put the dummy_float.obj on the linker command line _before_ the
library files. When the linker detects the printf reference in he
application program, it extracts the printf.obj from the library.
Since that printf module contains a reference to print_float, the
linker already knows where it is, since it has been provided by the
dummy_float.obj and does not need to retrieve the print_float.obj from
the library.

Paul
 

Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24
On Sunday, in article

Quoted text here. Click to load it

Forgot the one that is RARELY needed in embedded situations, and relying on
it, would mean a bad design anyway - printf returns the number of
characters output which I have not *yet* seen an application use.

Quoted text here. Click to load it

Makes a lot of assumptions, works on one library, for better code reuse
for MINIMAL footprints, use a stripped down one for usability on more
compilers and targets.

Quoted text here. Click to load it

Assuming the library module for that function, is actually a separate
module whereby you can save space, otherwise you will have it *POTENTIALLY*
included but not used.

That solution is very compiler/linker/library dependant.

--
Paul Carpenter          | snipped-for-privacy@pcserviceselectronics.co.uk
<http://www.pcserviceselectronics.co.uk/ PC Services
We've slightly trimmed the long signature. Click to see the full one.
Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24

Quoted text here. Click to load it

Some compilers can help with this.  For example HI-TECH says about a
feature of their upcoming "Pro" compiler series:

    "Automatic Generation of printf Code: The code associated
    with the C library function printf() has been removed
    from the library files. After a preliminary scan of
    the user's C source code, an appropriate printf
    routine is "written" by the compiler that will suit the
    function's usage, based on the placeholders used in
    the format string in calls to printf()."

--
Dan Henry

Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24
Quoted text here. Click to load it

point taken


--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
We've slightly trimmed the long signature. Click to see the full one.
Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24

Quoted text here. Click to load it

Not true. Library functions are immensely general purpose which largely
accounts for their bloat and their inappropriateness in small 8 bit
controller products. For simple printing of constant strings a user
function is far better.

Ian

Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24
Ian Bell schrieb:
Quoted text here. Click to load it

Printf variants do a lot more than simple printing of constant strings.
Otherwise they wouldn't take a few Ks.

Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24

Quoted text here. Click to load it

Precisely my point - they are general purpose routines and do a whole bunch
of things you don't need them too i.e. wasted space in a memory constrained
product.

Ian

Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24
Ian Bell schrieb:
Quoted text here. Click to load it

Nobody uses printf for simple printing of constant strings. If you need
only some of the functions like number formatting printf can already be
useful, and looking for a cheaper function while the program fits in
your target controller is wasted time.

Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24
Quoted text here. Click to load it

There's a serious danger of going round in circles here because that's just
what the OP was doing with printf.

Ian

Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24
Ian Bell schrieb:
Quoted text here. Click to load it

Where?

Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24

Quoted text here. Click to load it

Pass.

Ian

Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24
Quoted text here. Click to load it


Currently implementing "optimized" printf for a 4kB ATmega48 controller.
Sure make a difference in price compared to the 8kB ATmega88...

--
Best Regards,
Ulf Samuelsson
We've slightly trimmed the long signature. Click to see the full one.
Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24
Quoted text here. Click to load it

printf should NOT be used for debugging at all.
some parts only have 2-4 K of program memory.

Only ametures debug with printf on 78 bit micros.

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
We've slightly trimmed the long signature. Click to see the full one.
Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24
Chris Hills schrieb:
Quoted text here. Click to load it

Some parts have only 512B of memory - so what? Of course there are
exceptions.

Quoted text here. Click to load it

And what do professionals use?

Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24
Quoted text here. Click to load it

ICE or JTAG

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline