Mid-Range PIC C Programming Tutorials
The following tutorials build on the material covered in the mid-range assembler tutorial series, showing how to implement the example applications from those lessons, using Microchip's XC8 C compiler (running in "Free mode").
To get the most out of these lessons, you should purchase the Gooligum baseline and mid-range training and development board,
which was designed to complement this tutorial series.
|Search this site:
Download the free mid-range C lessons (1-5) as a single zip file: midrange_C_free.zip
or access them individually:
Click on the lesson title to read each lesson (PDF).
Right-click the source code links to save the code for that lesson to your PC.
Note: PIC12F629 Programming Issues
Workarounds for a couple of issues you may encounter as you work through the first lessons, especially if you are using a PICkit 2 programmer
|1: Basic Digital I/O
Using delay loops to flash an LED, reading and debouncing simple switches, and using weak pull-ups on mid-range PICs
|2: Using Timer0
Configuring and accessing Timer0
Using Timer0 for debouncing, background tasks, event timing and counting
(with an example of C macros)
|3: Introduction to Interrupts
Interrupt service routines, Timer0 and external interrupts, debouncing
|4: IOC, Sleep Mode and the Watchdog Timer
Using interrupt-on-change, sleep mode, and the watchdog timer
|5: Reset, Power and Clock Options
Oscillator (clock) modes, power-on reset and brown-out detection
Additional lessons included with the Gooligum training board
(also available for separate purchase on the main tutorials page)
|6: Analog Comparators
Using the single and dual comparators and programmable voltage reference
on the PIC12F629 and PIC16F684
|7: Driving 7-Segment Displays
Single and multiple 7-segment displays, lookup tables and interrupt-driven multiplexing
|8: Analog-to-Digital Conversion and Simple Filtering
Analog-to-digital conversion (ADC) and
using arrays and simple integer expressions to calculate a moving average
Using Timer1 as a general 16-bit timer/counter, with an external watch crystal,
operation in sleep mode, and digital and comparator gate control
Using Timer2 as a simple 8-bit timer, with period register and postscaler,
to generate a specific interrupt time-base
|11: CCP, part 1 - Capture and Compare
Using the CCP module's capture and compare modes to measure signal and pulse widths
and to trigger precisely timed events, including periodic analog sampling
|12: CCP, part 2 - PWM
Using the CCP module's pulse-width modulation (PWM) modes for tasks including
tone generation, LED dimming and bi-directional brushed DC motor control
Additional lessons are being compiled, and will be emailed to training board or CD purchasers, as they become available.
PDF files are read with free Adobe Reader software.
Return to Main Page