I am a long-time Mac user (or as long as you can be for a 16 year old), and when I started to experiment with embedded systems, I had to do quite a bit of reading around before I came up with a pleasant toolchain and workflow. This instructable will show you how to develop for PICs in a friendly, native-UI way (no terminal involved — apart from during set-up). Please note that, with a bit of tweaking, these steps apply just as easily to Atmel AVR programming, as I believe that command line compilers and programmer software is available for these popular MCUs.
Before we start, here's a rough outline of how we're going to do this: Using AppleScript and a customisable text editor we automatically perform compilation and download of code through a native Aqua UI, displaying any error messages along the way. We will also offer extra abilities, depending on the compiler/programmer software you're using.
On to the first steps!
Step 1: Gather the tools and software
You'll need a programmer — for those who are new to this, a programmer is a little device that plugs into your computer and your circuit, and transfers your compiled program onto the PIC/AVR. There are plenty of 'official' and unofficial programmers — I'm using a PICKIT 2 clone by Sure Electronics (They're an amusing Chinese company who print "Have fun with us" on their product boxes"), but you can use almost any programmer. The important thing is that it has a terminal interface, i.e. you can control it via the terminal. Examples of this include usbpicprog, which looks like a great little low cost PIC ICSP programmer.
For the PK2, this software is called pk2cmd, and can be downloaded from the 'Downloads' section of Microchip's PK2 Page .
Install whatever software you need for your programmer. You'll probably have to use Terminal for this section (Applications/Utilities/Terminal ). Follow the instructions in the readme or install files, and you can always post a comment if you get stuck!
You'll also need a compiler. This is a piece of software that turns your assembly language or C into machine code (raw hex values) that the MCU can understand. I'm using gputils's gpasm , an open-source clone of Microchip's mpasm. I hear that mpasm can be run on OS X, as can student versions of Hi-Tech C's C compilers.
Same deal as with the programmer software — download whatever compiler you want from respective websites (I can recommend gputils, and I'll be using that for this tutorial) and follow the installation instructions. I'm not going to go over every single problem that could occur, so post a comment if you need a hand.
You'll need a plain text editor that you can customise to run AppleScripts through a menu or button. Textwrangler is great because it's free, allows you to add AppleScripts to a menu, and is fully scriptable, which gives benefits you'll see later. It also does some syntax highlighting. Unless you know your way round AppleScript, use TextWrangler.
At this point you should be able to compile and download a program. If you can, check now and solve any problems before moving on to the next stage. At the very least, try to run both programs from the Terminal (by typing their names and pressing return. For example, "pk2cmd", and "gpasm".