OT: best resources for 'C' language from those here that dabble in raw pics too.

tony_g

Senior Member
well after about 2 years of playing with the picaxe i finally took the plunge to playing with the pic's in their native form.

in the last week since my pickit3 arrived i "retired" one of my 08M2 DIP chips and have been slowly working through various different tutorials i find to get more familiar with the mplabx workspace but more importantly the 'C' language.

i know that there are a good few members here who also like to use the native pics and so i am hoping that people can point me towards more beginner friendly 'C' language guides/tutorials and the like.

in the last week i dont know how much time i have spent searching and filling my bookmarks with umpteen pages to keep handy for reference when i get stuck or dont know the best way to work around something, what im hoping is that someone knows of a great source of beginners information about using the 'C' language that is straightforward enough to be able to read through and understand instead of sometimes ending up being more confused than i was to begin with.

i have found their are some great books available for embedded pic programming in c but often end up almost falling of my seat when i see a price tag of around $200!! i know that great knowledge that is relevant to what exactly one needs is going to have a price tag but unfortunately thats just way too far out of my reach these days,especially with a recent new addition.

i can happily say that regardless, the picaxe is still going to have a place in my circuit designs and is not getting brushed aside once i have a better grip on pics and c, its far too much a convenient tool to be able to do most of what i need and fast code prototype things but if i need more speed, then being able to do it with a raw pic is an added bonus.



thanks,
tony
 

Dippy

Moderator
A tricky one.

Years ago a chum of mine lent me 'Teach yourself C++ in 21 days'. It's aimed at PC rather than PIC but gives helpful advice regarding syntax.
I bought ME's C compiler (and PASCAL and BASIC) and learnt from examples alongside the book.

I'm sure there's many books targeted at PIC. Have you searched Amazon and similar?

I may have to get something too. I've just downloaded M'chip's recent MPLABX and started re-learning after a 2 year break.
So, I'll need a book too :)

In my local town we have one of those Old Fashioned things called a 'Library' so I'm going to visit that.

Blimey, I just realised; I still have his book!

One cheeky comment; if you are just doing hobby/home PIC stuff there are numerous BASIC compilers that might ease the passage.
At the very least they will highlight all the settings you need to do that PICAXE does for you behind the scenes.
PS. I cannot recommend ME's compilers.
 

inglewoodpete

Senior Member
I've done some development work on PIC32s and, more recently, PIC18Fs. I use Microchip's MPLABX and the MPLAB 18C compiler. Of course, you are working with a PIC12F chip.

All I can say is that I have had quite a bit of success but it is a hard slog! When working with the registers, timers and ports you can easily come to a halt. Researching a solution can take several hours or days of your spare time, so getting even the simplest of programs to work as required can take several weeks. Usually someone else has already struck the same or a similar problem. It helps to have a punching bag in the back room of your house, though!

The Microchip forums have a lot of useful information but many of the members are not as friendly or tolerant as the ones on this forum.
 

tony_g

Senior Member
thanks for the replies, a good book is definately on my list of things to acquire thats for sure, it seems to easy to get lost,confused or overwhelmed when looking for the right stuff that i need to help me understand better.

i did try to learn c last year when i was tempted to play with an arduino pro mini but i have to admit i gave up on it shortly after, i have got too comfortable with the ease of picaxe basic and the luxury of most of the hard work being done behind the scenes courtesy of the interpreter but i have managed to stick at it this time lol but i decided that it was something i should really try to learn as it would be beneficial, i just keep telling myself that it was like this when i first started playing with the picaxe with no prior knowledge/experience before that (and the occasional mumbling rant when i get annoyed).

as for the forum hmmm, i did ask for help once and the way they "tried" to help me ended up causing more confusion for a bit and the way they worded their response when i posted my revised code did come across as maybe a bit bold or brash,not as great as the community as a whole that exists here, darn this forum has just set an impossible bar for any other to even come close to now lol.

well i have finally decided its time for bed now (nearly 4am) seeing as i have finally managed to get this project working for now, dual RC receiver pulsin and pulsout with a nice 11ms (ish) frame rate for some ridiculously strong holding torque, although it is far from done more just another playing/learning exercise but its a start

thanks for your insights gentlemen and good morning :p


tony
 

AllyCat

Senior Member
Hi Tony,

The "bible" of the C language is by "Kernigan and Richie", which appears to be about $40 in paperback, but available as a free (.PDF) download, for example from here (warning: it will start downloading 288 pages, perhaps in an "image" format ! ). Maybe worth a look to see if you find it useful.

However, I must admit that I "struggle" with C, even after having taken a formal training course; maybe it's my background (from 40+ years ago) of Fortran, Basic and many flavours of Assembler. So I echo Dippy's suggestion of seeing if you can find a suitable Basic Compiler for the PICs.

Cheers, Alan.
 

1968neil

Senior Member
Hi Guy's,

Have a look at Matrix Multimedia's "Flowcode" this ive used in the past and find it quite intuitive and its available in all flavours, PIC, ARDUINO,ARM etc.
It compiles all the code to C or Assembler so you can get some idea of what the code should look like.
Personally despite the interpreter overheads i find PICAXE a great option ;)

Regards
Neil
 

lbenson

Senior Member
I would repeat AllyCat's recommendation of "Kernigan and Richie"--I referred to it repeatedly when learning C back in the early 80s (with the same background as AllyCat--Fortran, Cobol, various assemblers), and it was invaluable for clarity. But it will not help you greatly with the foibles of controlling inputs and outputs on a microprocessor.

Needs differ, but even after having written thousands of lines of C code (for 8086 microprocessors + some mainframe code), I would have to be hard pressed for technical reasons to use C for hobbyist projects.
 

geoff07

Senior Member
Unless you actually need the raw speed of a native PIC, and not many applications will, I would think of C as learning instrument rather than a hobby solution. Learning the language is the easy part. But the language manuals are implementation-neutral and do not explain how the interface with the hardware works. Learning how to use e.g. MPLABX, the various free compilers, the necessary libraries and header files, setting up the PIC config, using PICkit and then debugging what will become almost a black box will be where the work is. Not to mention the PIC datasheet (maybe 500 pages) and how to use the registers and so forth. Very interesting and good experience, but once dabbled you will come to appreciate what RevEd have done in the Picaxe firmware. One complex command in Picaxe Basic can be worth hours (literally) of research into how the PIC works, how to control how it works, and how to apply that to your problem.

I wouldn't want to put you off, but be prepared to do the work!
 

tony_g

Senior Member
thanks for the further input everyone.

after this last week of playing with mplabx and the xc8 compiler i can say it does give more appreciation for the ease of the picaxe system, and after going through the ritual of just measuring 2 seperate pulse lengths its clear how much work is done behind the scenes to get a simple command such as "pulsin" to do its magic.
even when using the "easy method" of the timer 1 gate in single pulse mode then switching the pin function to do it all again on a different pin.

ill have to admit dealing with the registers and appropriate bits to setup each function i want to use was not as bad as i thought once some time is spent looking over the datasheet but it seems the hardest part for me is the language change which the old grey matter seems to try and resist these days but when i do work something out it still has its moments when i sit their wishing their were some good reference manuals like with the picaxe to help out.

but the only reason for the change was to gain some speed increases for certain things when needed and their are plenty of other options available to get that so i guess i just need to look around and find something that seems a little less intimidating to learn than using the xc8 compiler, although i think i will still look at getting a suitable book for 'C' as it is a language that is worth trying to make more sense of and the Kernigan and Richie book is one that does pop up in reference amongst my many various google sessions, and darn cheaper than that embedded pic c book with the hefty price lol.


thanks everyone,
tony
 
Top