Friday, February 6, 2009

ADC using C18 compiler

Since I'm tired of using assembly to program my pics, I quit and started using the C18 compiler.

Turns out, that since the C18 compiler is not free, there is way less documentation by hobbyists. This makes starting up on your own extremely hard. In addition, the documentation on the C18 compiler by Microchip isn't that great. However, because I have been using assembly so far, I was able to guess my way through setting up a program to do analog to digital conversions.

My first PIC-C program reads the potential difference across a junction on the circuit and ground, and compares the values to Vdd-Vss. If the conversion value is less than 512 (2.5V) it turns one LED on, otherwise it turns the other LED on.

Here is the link to the program: adc.c
As you can see, it takes much less work than setting it up in assembly.