Monday, 4 July 2016

Getting comfortable with Microchip PICs again

We've been doing a lot of work lately with Arduino. A lot of people love it, because you can just copy-n-paste some code off the intertubes and get a project running quickly. But that's also the reason why we really don't like it so much.

Recently we discovered another problem with the AVR chips (other than they let out the magic smoke really easily if you're not careful with the power supply!) regarding programming fuses. It's something that a lot of Arduino users never have to bother with. And as a result, there's not much information out there about it. And the bit of information out there usually involves the "copy-and-paste this code and everything will be ok" approach.

So when things don't work, it can take a long, long time to get to the bottom of things!

It was with relief that we returned to programming PICs again this weekend. Rather like having had a heavy night out in some new shoes, it was lovely to come home and put on an old, battered, but ultimately, really comfy pair of slippers. That's how I - personally - feel about PIC programming.

Now we've a bunch of 16F1829 chips lying around, so it made sense to use these for a new project. Since discovering the 16F1825, with it's 32Mhz internal oscillator and billions of onboard peripherals, it quickly became our favourite - and thus our go-to - PIC of choice. The 1829 is the same, but with more pins. And more pins means better, right?

Anyway, it was with some concern that we wired one up only for it to be unrecognised by our PICKit2 clone programmer.

We've got three or four of these, and not a one of them programmed the chip.
So we checked the wiring. It looked ok.
We were using a SOIC-clip to program a surface mount version of the chip.

Perhaps the problem was with the clip - so we put an SMT chip onto a breakout board.

Still nothing. Yet the chip was brand new and appeared to be wired correctly.
Then I remembered that I nuked my laptop a couple of months ago. Around about the same time we started playing around with Arduino.

It turned out that the PICKit2 software (re-installed after the nuking a while back) was running the older (original) device file. To support newer chips, like the 1825, you need to update the device file for the PICKit2 software. There's an updated file available by searching the Microchip forums. For anyone looking for it, we've uploaded the file to the nerd-server:

Now the software can find our device and we can easily burn firmware to our PICs again. Lovely.
Arduino is already beginning to feel like a distant memory....

No comments:

Post a Comment