PIC16F690/PIC16F1938 Library
This is a library that makes it very simple to program a PIC16F690 or PIC16F1938. I created this for use to an introduction to programming class so that students could create custom embedded projects without having to understand the microcontroller hardware. The library assumes you are using an external 4MHz crystal. You can edit utilities.(c/h) to reflect your hardware setup.
The library is split up into two sections, utility.(c/h) and lcd.(c/h). The first section, utility, is a set of helper functions for setting up and using the microcontroller hardware.
The utility library includes helper functions to:
- Initialize the microcontroller hardware.
- Configure the analog and digital I/O pins.
- Set the state of digital outputs and read the state of digital inputs.
- Read an analog input.
- Delay the program for specified numbers of milliseconds or seconds.
The lcd library is for use with a two line HD44780 based character LCD display. It features helper functions to:
- Initialize the LCD for 4-bit communication.
- Clear the screen.
- Move the cursor between lines.
- Write commands and characters to the LCD display.
- Use printf() to write formatted strings to the display.
- Print floating point numbers to the display.
The project site has a Wiki that provides function by function documentation on the library. It should be able to answer any questions you have.
Included in the project is an example_main.c file which shows basic usage of the library. An LM35DZ temperature sensor is connected to an analog input. The temperature is read, converted to Celsius, and then displayed on an LCD character display.
The source can be easily modified to handle different microcontrollers. The link to the bitbucket site is found below. If you use Mercurial, you can also clone the project with the following command: