EmbeddedRelated.com
Forums

Best PIC family for C programming

Started by Staiger September 19, 2008
Colleagues,

In recent threads a number of you have sounded words of caution about using
C for the "smaller" PICs, such as the 12- and 16-families.

What would you recommend as a sensible PIC family for programming in C?

To put this into context, I have used C successfully with small projects,
most notably with the 16F818, and also the 12F509 and 16F84. But I'm not an
expert and appreciate that more ambitious projects might run into trouble
with these families.

Your thoughts on good PICs for C programming would be much appreciated.

Thanks,

SteveT
> What would you recommend as a sensible PIC family for programming in C?

Can not be answered without more details. If you want to use the full
power of C (especially recursion) 12 and 14 bit cores are definitely
out, probably 16-bit cores too. OTOH, for small projects a 10F200 might
be the prefect choice.

--

Wouter van Ooijen

-- -------
Van Ooijen Technische Informatica: www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: www.voti.nl/hvu
--- In p..., Wouter van Ooijen wrote:
>
> > What would you recommend as a sensible PIC family for programming
in C?
>
> Can not be answered without more details. If you want to use the full
> power of C (especially recursion) 12 and 14 bit cores are definitely
> out, probably 16-bit cores too. OTOH, for small projects a 10F200 might
> be the prefect choice.
>
> --
>
> Wouter van Ooijen

Here I thought I was missing something about the 10F series so I
grabbed the datasheet. Clearly, the 10F200 isn't going to use C with
only 256 words of flash and 16 bytes of SRAM.

The PIC18 series work pretty well with C and projects that do things
like USB and ethernet. I did a little project with one of the 18F
chips to interface a PS2 game controller to a PC by having SPI on one
side and USB on the other. It worked very well and the Microchip C18
compiler is quite good (in that it works).

But you have to take this C thing in context. You can't use a PIC to
solve world hunger or predict weather patterns. But if you just want
to write code for the hardware gadgets and control things connected to
the pins, C will work on most of the 16F series.

I have been using cc5x for years on 16F parts including my favorite,
the 16F88. Sure, the language is a subset and I can't put function
pointers in arrays and, true, it doesn't handle expressions very well,
but it works.

I have also used PIC C Lite and I could be convinced it is a better
compiler. I just reach for cc5x more often. Go with what you know, I
guess.

Richard

> Here I thought I was missing something about the 10F series so I
> grabbed the datasheet. Clearly, the 10F200 isn't going to use C with
> only 256 words of flash and 16 bytes of SRAM.

Why not? If the project is simple and the compiled result is within the
chips limitations, why worry? There is no smaller/cheaper PIC, so doing
it all over in assembler to save space would be a waste of time.

> The PIC18 series work pretty well with C and projects that do things
> like USB and ethernet. I did a little project with one of the 18F
> chips to interface a PS2 game controller to a PC by having SPI on one
> side and USB on the other. It worked very well and the Microchip C18
> compiler is quite good (in that it works).
>
> But you have to take this C thing in context. You can't use a PIC to
> solve world hunger or predict weather patterns. But if you just want
> to write code for the hardware gadgets and control things connected to
> the pins, C will work on most of the 16F series.

I agree. But watch out with '16F' : some are 12-bit cores with (for
instance) only 2 stack levels. Better talk about 12, 14, 16 bit cores.

> I have been using cc5x for years on 16F parts including my favorite,
> the 16F88. Sure, the language is a subset and I can't put function
> pointers in arrays and, true, it doesn't handle expressions very well,
> but it works.

It works for you, but it would not work for someone who expects some of
the features you don't use.

--

Wouter van Ooijen

-- -------
Van Ooijen Technische Informatica: www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: www.voti.nl/hvu
>>

I agree. But watch out with '16F' : some are 12-bit cores with (for
instance) only 2 stack levels. Better talk about 12, 14, 16 bit cores.

<<

That's a good point: I hadn't appreciated that some have just two stack
levels.

Is there a basic correlation between the 10, 12, 14, 16 and 18 families and
the 12, 14 and 16 bit cores?

The numbering system seems pretty confusing to me, especially as, in
addition to the different instruction width, there are 8, 16 and 32 bit data
busses!

Remarkably, there doesn't seem to be a basic chart or list showing the
various PICs against those two parameters anywhere on the Microchip site.

SteveT
The 18F parts are nice. The 18F4620, 18F4550, etc. have worked well for me.

Alan KM6VV

---

On Behalf Of Staiger
Colleagues,

In recent threads a number of you have sounded words of caution about using
C for the "smaller" PICs, such as the 12- and 16-families.

What would you recommend as a sensible PIC family for programming in C?

To put this into context, I have used C successfully with small projects,
most notably with the 16F818, and also the 12F509 and 16F84. But I'm not an
expert and appreciate that more ambitious projects might run into trouble
with these families.

Your thoughts on good PICs for C programming would be much appreciated.

Thanks,

SteveT
> Is there a basic correlation between the 10, 12, 14, 16 and 18 families
> and the 12, 14 and 16 bit cores?

It is very simple!

:)

10 is for 6-pin chips, but they can be in 8-pin dip with two unconnected
pins. currently all are 12-bit cores.

12 is for 8-pin chips. Both 12 and 14 bit cores.

16 is for 12/14 bit cores with >8 pins.

18 is for 16-bit cores. no 6 or 8-pin 16-bit cores exist.

L is for low-voltage

C is for eprom/otp chips, F is for flash chips, *except* for 16c84,
which is (for all practical purposes) a flash chip

> The numbering system seems pretty confusing to me,

The guy who dreamed up the system must have been smoking some
interesting stuff.

> especially as, in
> addition to the different instruction width, there are 8, 16 and 32 bit
> data busses!

I have no experience with the >8 bits data PICs.

--

Wouter van Ooijen

-- -------
Van Ooijen Technische Informatica: www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: www.voti.nl/hvu
----- Original Message -----
From: "Wouter van Ooijen"
To:
Sent: Friday, September 19, 2008 2:06 PM
Subject: Re: [piclist] Re: Best PIC family for C programming

> I have no experience with the >8 bits data PICs.

The dsPIC30F's were the first of the 16 bit parts, and as a result, they
keep the same semi-random numbering of the 8 bit parts. However, the 3.3
volt parts (33F, 24F, 24H) actually have some rhyme and reason.

The HJ parts are "high-speed". 24H's are very fast, much faster than 24F's,
but only a little faster than 33F's

The next digits represent the number of K-bytes of flash

Then there are letters which represents the application. This really has to
do with the emphasis of the peripherals. A motor control (MC) PIC will be
heavier on PWM outputs and encoder inputs than a general purpose (GA) part.
There will then be a digit to differentiate between several parts with the
same intended application.

Finally, there will be two digits indicating the pin count.

Thus, you have ten dollar names like PIC24FJ128GA010

The PIC32's aren't really PICs at all, and I get the impression from their
numbering that they may well be temporary.

By the way, as I mentioned before, if you are bound and determined to do
your programming in C, I would strongly suggest the 16 bit parts. Memory is
large enough that you can actually write C instead of some vague
approximation, the instruction set is far more friendly to C compilers than
the 8 bit parts, the compiler is free, and the parts cost barely more than
the 8 bit parts. Plus, some of the 16 bit peripherals are way cool.

72/73 de WB8RCR http://www.qsl.net/wb8rcr
didileydadidah QRP-L #1446 Code Warriors #35
>>

By the way, as I mentioned before, if you are bound and determined to do
your programming in C, I would strongly suggest the 16 bit parts. Memory is
large enough that you can actually write C instead of some vague
approximation, the instruction set is far more friendly to C compilers than
the 8 bit parts, the compiler is free, and the parts cost barely more than
the 8 bit parts. Plus, some of the 16 bit peripherals are way cool.

<<

That is very handy advice, thanks.

To be fair, though, I must tell you that I've done lots of small projects in
C on stuff like the 16F84 and the 12F509. Of course, these have been simple
applications, but it's still all done in C rather than assembler.

Having said that, I'm going to take a close look at the 16-bit parts.
Thanks again for that steer.

SteveT
--- In p..., "John J. McDonough, WB8RCR"
wrote:
>
> ...
>
> By the way, as I mentioned before, if you are bound and determined
> to do your programming in C, I would strongly suggest the 16 bit
> parts. Memory is large enough that you can actually write C instead
> of some vague approximation, the instruction set is far more
> friendly to C compilers than the 8 bit parts, the compiler is free,
> and the parts cost barely more than the 8 bit parts. Plus, some of
> the 16 bit peripherals are way cool.

John, what compiler is that, and where can we find it?

In past searches of the Microchip site, I must have missed it. Perhaps
I saw it, but didn't realize that there is no charge for it.

Best regards,
John
Germantown, Ohio