Book recommendations for the PIC microprocessor.
March 31, 2006 9:09 AM   Subscribe

Geeky BookFilter: I'm looking for a good book on PIC Microprocessors. Details of the specific knowledge I'm seeking inside.

I've done electronics work... I'm not afraid of a solder gun, a multi-meter or deciphering the ohms of a resistor from the color bands. I've even done NIST certification chain calibration of medical test equipment.

I have worked on a limited basis with microprocessors before, but not from scratch. I helped program someone else's creation. I do not need a general programming book. I need specifics.

So I'm looking for something in the intermediate to advanced range. I want something to cover what makes PICs tick, so to speak, and then I'm very much specifically interested in interupt based uART communications.
posted by killThisKid to Technology (11 answers total) 2 users marked this as a favorite
May I recommend Physical Computing: Sensing and Controlling the Physical World with Computers? It's written by Dan O'Sullivan and Tom Igoe, who teaches a class in physical computing, which currently uses the PIC. It is not a book specifically on the PIC, but more on how to use microprocessors with sensors. Given your level, it might not be as advanced as you need it, but it may be a good resource for you.
posted by hooray at 9:53 AM on March 31, 2006

Best answer: Myke Predko's Programming and Customizing PICmicro® Microcontrollers is pretty good, but if you try to build out the programmer PCB, be warned that the PCB I got was one of the worst made in the world, and traces would peel off if you looked at it funny.

PICs are odd beasts, but that oddness is what makes them very powerful for their size. If you're used to the C world, the whole idea of Data and Program memory being seperate isn't really going to help.

To get good, you really need to learn the PIC assembler. There are lots of high level tools, but if you need to push the hardware, you'll take the assembler output, and then tweak that. Me? If I need more speed, I get a faster PIC. (If you need way fast and PIC, the Scenix SX are PIC compatible, but blazing fast.)

Having said all of that. Interrupt based uART comm is now easy on the PIC, given that most of the new PICs have UARTs on them. To drive RS-232 serial, you really need something (MAX232) to get the voltages right, but the rest is built into the PIC itself.

The traditional PIC to start with is the 16F84. Don't. Time has passed, and the only reason to buy one now is you're building something that specs a 16F84, and you don't want to change the code. The 16F628A [pdf datasheet] is everything that 16F84 was, but with the USART, an onboard oscilator, PWM, more code memory, more data memory, and more EEPROM. Even better is the 16F648A [same sheet as the 628A], identical to the 628A with twice the code space, and the killer 16F88 [pdf datasheet], which is all that the 16F648A is, plus a 7 channel ADC and SPI/slave I2C interfaces.

There's an argument that if you're learning new, you should ignore the 12 and 16 series PICs unless tiny is really good, and learn the 18F and dsPICs right off the bat.

If you're really wanting to use C or something like it, there are compilers out there, but they're really odd version of C, unless you use the not-PIC like 17 series PICs. I don't know anything about the new 24 series 16 bit PICs.

Global list of the 8bit PICs here, and you can select by feature here. The Microchip datasheets are very, very good -- it's perfectly possibly to learn PIC assembly from them alone.

For 8 pins, I like the 12F675 (the 12F629 is similar, without ADC, but unless you're dealing with lots of them, stocking two makes is silly.) The 16F676 is basically the 12F675 with more pins (handy for feature creep.) Microchip has also added the 16F690, in case your 16F628A has creeped, it adds two more pins. The mighty 16F877A [pdf ds] is still popular if you need lots and lots of pins and features, but they've been updating them somewhat as well (but mostly moving those who need that much hardware to the 18 series, and now, the 24.)
posted by eriko at 11:45 AM on March 31, 2006

I found a book that included a PCB to make to your own PIC programmer, and a CD-ROM to use it. Thus I knew that the book would be compatible with my hardware and software, so I woulkd be able to follow the tutorials without any hassle of trying to work out how to do this or that in a different environment.

The programmer was easy to assemble, few parts, but I got sidetracked into other projects and didn't work very far into the book. It focused on assembly language though, rather than something higher level. Anyway, I can't recall the name, but I'll have a look for it when I get home. I mainly just thought that mentioning the book+software+programmer route seems the easiest way. Today however, I'd get a
book+software+programmer set that included BASIC or C or something. These cost more, since the language and compilers aren't free like the assembly ones are, but I'm not big on assembly :)
posted by -harlequin- at 6:52 PM on March 31, 2006

I followed eriko's first link, and that's the book I was talking about. Now that I think about it, I can't recall if it had a CD-Rom - it might have referred you to a website for a download.
posted by -harlequin- at 7:05 PM on March 31, 2006

Personally, I'm a fan of the Microchip datasheets. They're excellent: learn the assembler, figure out the register map and you're all set.
posted by polyglot at 9:57 PM on March 31, 2006

Response by poster: Thanks everyone, esp. Eriko, that's the sort of kick-butt metafilter answer I was looking for.

I'm definately using the 16F88 along with the dev board from sparkfun.

I don't need rs232 levels, I'm going to attempt to talk to a usbWiz.
posted by killThisKid at 7:35 AM on April 1, 2006

I don't need rs232 levels, I'm going to attempt to talk to a usbWiz.

The 16F88 is the right answer then -- it really is the Perfect 18 pin PIC right now.
posted by eriko at 10:05 AM on April 1, 2006

Response by poster: Eriko, if you're still following this thread, what would you recommend for a C compiler, free and otherwise?
posted by killThisKid at 12:08 PM on April 3, 2006

what would you recommend for a C compiler, free and otherwise?

On the PIC? None, for two reasons.

1) I hate C and all it stands for. ;)

2) The PIC, using the Harvard Architecture, is fundamentally at odds with the design decisions of C.

There are C compilers, none free, all constrained in odd ways because of the nature of the PIC. The best are the ones Microchip built for the 17 series PIC, which support some of the 18 series. Between the architecture and the limited memory space (for example, the 16F628A can handle 2048 14 bit words of instructions, which operate on 224 bytes of RAM, with 128 bytes of EEPROM for onboard storage,) this isn't a realm that C plays nicely in. The best languages for the pic get as far away from the hardware as they can, and tend to be the "this easy word becomes this simple stack of assembler instructions" -- Forth, Pascal, and Basic[1] would be much easier to implement than C (indeed, that's what most people have done, see PicBASIC, the Basic Stamps, there's a Forth tool out there, and JAL, which is sort of Forth-meets-Pascal.)

If you want to do C on a microcontroller, the right answer isn't to find a C compiler for the PIC, the right answer is to find a different microcontroller that already has C compilers built for it. Heck, gcc supports the Atmel AVR and the Motorola 6811/6812 series microcontrollers directly.

The new 24 series PICs may be a different beast (they are, in the sense that they work with 16 bit data, not 8 bit.)

Caveat: I am not a real programmer, I'm a sysadmin, and Unix has made me bitter. There may well be a real C out there for the PIC, but I don't know what it is, and nobody I know has used it either. Most working with C on PIC are using Microchips's C on the 17 series PIC (and maybe the new 24 series, but I know little-to-nothing about the 24 series.)

[1] This is Basic without linenumbers, not the Microcomputer Basic many grew up with. Different world -- procedure calls, not GOTO 10.
posted by eriko at 5:45 AM on April 4, 2006

Response by poster: Heh, great eriko, that's a good rant.

Ok, so what do language do you program you PICs in? How do you do it?
posted by killThisKid at 8:34 PM on April 4, 2006

I've been using Jal and Assembler, but I just came across this site, which offers various Pic development things, including Basic, Pascal and C compliers.

The prices are reasonable, but even better, you can download them and try them for free, with the main limitation being that you only get 2K of output code. But, hey, if you're coding for 16F628As, that's all the space you have.

Worth a try to see if it's C enough for you. I may well try it myself, or at least try the others.
posted by eriko at 9:03 AM on April 7, 2006

« Older Eating meat again   |   What is the best introductory book to corporate... Newer »
This thread is closed to new comments.