The initial intent was a companion package to our $139.00 PIC16F87X Development Package which includes an MPLAB In Circuit Debugger, an Optrex DMC20434 20X4 LCD and 74HC595 shift register, a momentary pushbutton, 10K potentiometer, a 32.768 kHz crystal, speaker, 10K NTC thermistor and 5V LEDs plus the Morgan Logic Probe. The intent is to provide the hardware to illustrate most of the features of the PIC16F87X family.
Initially, the scope was limited to sample routines for the PIC16F87X. The routines were written using CCS Info's PCM PIC C compiler and were periodically mailed to those who had purchased the PIC16F87X Dev Package as new routines were developed. In 2001, this consisted of five distributions which total some 270 pages of discussion and some 80 sample routines.
Subsequently, the focus has been widened to include other PIC processors which are not supported by the MPLAB In Circuit Debugger
In August, '01, the distribution was related to low end Microchip PICs; PIC12C508/509/CE518/CE519, 16C505 and 16HV540 using the CCS PCB compiler and 12C671/672/CE673/CE674 using the PCM compiler. This consisted of 120 pages plus 75 routines related to these low end Microchip PICs.
In Jan, '02, the distribution focused on the PIC18C452 using the CCS PCH compiler. This consisted of 105 pages plus 40 sample routines.
The next distribution will be in the Sept, '03 and will focus on topics related to the PIC14000, PIC18Fxx2, PIC16F87xA, PIC12F675, PIC16F676, PIC16F819, PIC16F1320.
All of this material which has been developed to date is immediately distributed at no charge to those who purchase our PIC16F87X Development Package.
It is also available to others for a one time payment of $39.00.
The distribution consists of a mailing (snail mail) of a few schematics associated with early routines developed for the PIC16F87X In Circuit Debugger. All other discussions in .pdf format and the source code in .zip format is distributed via e-mail.
Additional material that is developed in the future will be distributed to all subscribers at no additional charge. However, $39.00 is pretty reasonable in saving you countless man hours and I cannot make a commitment as to how much material will be developed in the future. You might look it as the $39.00 buys a lot of effort and anything else beyond this is a bonus. The $39.00 does not buy a servant for life.
Note that I don't sell one or two routines. I do not sell this to book stores.
defs_877.h - Header file which defines all SFR registers and bits.
lcd_out.c and lcd_out.h - Routines for controlling the LCD including initialization, clearing the LCD, clearing a line, positioning the cursor, displaying quantities in decimal and hexadecimal formats and displaying characters. Routine lcd_char may be used with printf to display text and quantities. lcd_out.c also includes loop timing routines.
tst_lcd.c - Illustrates the use of the various functions in lcd_out.c.
font.c - Sequentially displays 0 - 255 in decimal, hex and as a character on the LCD.
flash_1.c and flash_2.c - Continually flashes an LED five times with a three second delay between bursts.
dial_1.c - Illustrates a telephone dialer which might be used in a remote monitor or alarm. Depression of a pushbutton causes the processor to operate an LED (dial pulse relay). Following a brief delay to assure dial tone is probably present, the processor dials the telephone number, waits for a party to answer and then sends the quantity in the form of zips (or beeps) using a speaker. For example, the quantity 103 is sent as one beep, followed by ten beeps, followed by three beeps. This is repeated three times and the processor then hangs up.
toggle_1.c - Illustrates use of an external interrupt. Depression of the push button causes an LED to reverse state.
ad_1.c and ad_2.c - Illustrates performing an A/D conversion using polling and interrupts. Continually displays the voltage at the output of a potentiometer and the angle of the setting.
toggle_2.c - Continually performs A/D conversion as above and displays while also toggling LED in response to a depression on the push button.
pwm_1.c - Illustrates the use of the CCP1 module in the PWM mode. Duty cycle is varied in response to depression the push button.
pwm_2.c - Varies PWM duty in response to setting of potentiometer using an A/D.
pwm_3.c - Same as pwm_2.c except that the routine illustrates 10-bit PWM.
timer2_1.c - Uses timer 2 to generate a 500 Hz tone on the speaker using interrupts which frees the processor to perform other tasks at the same time. When the push button is depressed, a 500 Hz tone is continually generated and A/D conversions on Channel 0 are performed and displayed on the LCD.
timer1_1.c - Illustrates the use of the 16-bit Timer 1 in conjunction with a 32.768 kHz crystal to time for one second periods. At the end of each second, the elapsed time in seconds and in hour, minute, second format is displayed and the speaker is beeped for nominally 200 ms using Timer 2. Illustrates the passing of a structure by reference.
therm_1.c - Extends on timer1_1.c to also periodically perform a second A/D conversion on Ch 1 which is configured with a series 10.0K fixed resistor and a nominal 10K negative temperature coefficient (NTC) thermistor in a voltage divider arrangement. The A/D value is used to determine the resistance of the thermistor (r_therm) and this is used to determine the temperature which is displayed in degrees C and degrees F on the LCD display.
therm_2.c - Extends therm_1.C to also sequentially write ten A/D measurements to program EEPROM memory. This data is then fetched from EEPROM and the results are displayed on the LCD.
eeprom_1.c - Illustrates the use of the data EEPROM. EEPROM location 0x00 is set to 100 on download. An LED is flashed while continually decrementing the EEPROM. When at zero, the program locks.
ee_save.c - Illustrates how to save floats and structures to EEPROM and retrieve them from EEPROM.
first_tm.c - Illustrates an implementation of first_time which determines if this is the first time the program was executed. If so, a serial number from an external device such as a DS2401 is read and saved to EEPROM. On each subsequent execution of the program, the serial number of the external device is compared with that stored in EEPROM and if they agree, the program is executed. Otherwise, the program is locked.
tmr0_1.c - Illustrates the use of TMR0 to produce a nominal 500 Hz tone on a speaker and toggle an LED every four seconds whicle continually displaying a screen message on the LCD.
count_1.c - Uses Timer 1 to time for one second and Timer 0 as a counter on the T0CK1 input. Displays the count to the LCD.
capture_1.c - Measures the period of an input on CCP1/RC2 and displays the result in usecs on the LCD. Illustrates use of the CCP module in the input capture mode.
capture_2.c - Similar to capture_1.c except measures the logic zero and logic one time of a waveform on CCP1/RC2.
out_cmp1.c - Uses CCP1 configured as "set on match" and "clear on match" to pulse an LED on for 1.25 secs and off for 4.0 secs while continually displaying a message on the LCD.
out_cmp2.c - Extends on the above to also include the use of CCP2 configured for a software interrupt every 50 ms. On a software interrupt, a pushbutton is scanned and a value output on the LCD.
out_cmp3.c - Uses CCP2 in the trigger a special event mode to perform an A/D conversion on Ch 0 and display result to the LCD. Also continually displays a message on the LCD.
bits_1.c - Illustrates the use of bit fields
union_1.c - Illustrates the use of unions.
calib_1.c - Illustrates the use of a potentiometer to set a value.
25_640bb.c - Bit bang implementation of SPI. Interface with 25LC640
EEPROM.
25_640_1.c - Illustrates use of the SSP module in SPI mode. Interfaces with Microchip 25LC640 EEPROM, byte write and read.
25_640_2.c - Similar to 25_640_1.c except block write and read.
2543_1.c - SSP, SPI. Interfaces with Texas Instruments TLC2543 11-channel, 12-bit A/D, single measurements.
2543_2.c - similar except multiple measurements.
3208_1.c - SSP, SPI, Interfaces with Microchip MCP3208 8-channel,
12-bit A/D. Includes single end and differential measurements.
7219_1.c - SSP, SPI. Interface with a MAX7219 Eight 7-seg Display
Driver.
ds1305_1.c - Real time clock. SPI Master. Writing and reading time.
Writing and reading RAM.
at41_1.c - Interface with an Atmel AT45D011 1-megabit Serial
EEPROM. SPI Master.
i2c_bb.c - A collection of low level I2C routines using bit bang
24_256_1.c - Interface with Microchp 24LC256, random and sequential write and read,
bit bang I2C
i2c_mstr.c - Collection of low level I2C routines using the MSSP in Master
I2C Mode
24_256_2.c - Interface with Microchp 24LC256, random and sequential write and read,
Uses MSSP in I2C Master Mode.
MAX518_1.c - Interface with Maxim MAX518 Dual D/A. I2C.
8574_1.c - Interface with Philips PCF8574 8-bit I/O. I2C.
1803_1.c - Interface with Dallas DS1803 Dual Potentiometer. I2C.
DS1624_1.c - Interface with Dallas DS1624 temperature and EEPROM.
1307_1.c - Interface with Dallas DS1307 RTC.
8583_1.c - Interface with Philips 8583 RTC and Counter. Illustrates how to write and read time.
8585_2.c - Illustrates an implementation of a dated alarm to generate an external interrupt.
8583_3.c - Illustrates use of timer alarm feature.
8583_4.c - Same as 8583_2.c except 8583 is in event count mode.
8583_5.c - Same as 8583_3.c except event count mode.
_1_wire.c and _1_wire.h. Low level rotuines for interfacing with Dallas 1-wire devices.
1820_1.c - Interface with a Dallas DS1820 (DS18S20). Uses "Skip ROM"
to measure temperature.
1820_2.c - Reads serial number from DS1820 and saves to PIC's flash EEPROM. Then continually reads serial number from EEPROM and uses "Match ROM" to perfrom a temperature measurement.
1820_3.c - Implementation of 8-bit cyclic redundancy check.
ser_87x.c and ser_87x.h - A collection of RS232 routines using the PIC's UART.
tst_ser2.c - Illustrates outputting data via UART to BasicX Serial LCD+ (or to standard terminal)
tst_ser3.c - Extends on tst_ser2.c to illustrate fetching an input string, either by specifying the terminal character or specifying the number of characters to fetch.
get_char2.c - Same as tst_ser3.c except uses "rda" interrupt with a circular buffer to receive characters.
.
spi_slv2.c - Illustrates operation of PIC16F877 in SPI Slave mode. On receipt of command send nine bytes back to master and performs a temperature measurement on the specified DS1820. Also includes TST_SPI.BAS - routine for the BasicX BX24 to control the PIC.
I2C1.BAS, I2C2.BAS, I2C_BX24.BAS, SerCom3.Bas, LCDCntrl.Bas. Routines for the BX24 as a Master I2C Controller.
i2c_slv1.c - Operation of PIC16F87X in I2C slave mode. On command from BX24 returns nine bytes which are displayed on an LCD connected to the BX24.
i2c_slv2.c - same as i2c_slv1.c except on command, either performs a temperature measurement using a DS1820 or flashes an LED a specified number of times.
The following routines are of a weather montoring nature.
humid_2.c - Illustrates an interface with a Honeywell HIH-3610 to
measure relative humidity.
barom.c - Interface with a Motorola MPX4115 pressure sensor.
wind_dir.c - Use of a dual potentiometer to determine wind direction
DS2438_1.c - Use of a DS2438 (1-W) Battery Monitor to measure
Temperature,
V_DD and V_AD.
DS2438_2.c - Use of a DS2438 Battery Monitor and Honeywell HIH-3610 to
measure temperature and relative humidity.
SER_BB.C - Illustrates an implementation of an RS232 9600 baud
interface using software "bit-bang".
DS2435_1.C - Interface with Dallas DS2435 (1-W) Time / Temperature
Histogram. Illustatres performing a temperature measurement, reading the
ID, clearing, incrementing and reading the counter, setting the sampling
time, setting and reading the elapsed time.
DS2543_2.C - DS2543. Illustrates setting of temperature boundaries,
clearing the histogram, reading and displaying the histogram.
DS2543_3.C - DS2543. Writing to and reading from scratchpad, transfer
between scratchpad and NVRAM. Illustrates saving an array, float and byte
to memory.
keypad_1.c - An interface with a 4X4 keypad. Uses PORTB Interrupt on change. Displays value of
depressed key.
keypad_2.c - Adds a 20 byte buffer such that main() can fetch depressed keys when convenient as
opposed to "camp on" to monitor the keypad.
keypad_3.c - Adds a serial interface such that on receipt of a character the keypad buffer is sent to
master processor.
keypad_4.c - An implementation of keypad_3.c for the PIC16F628.
ee_flsh.c - Reading from and writing to flash EEPROM. Moves storage locations in flash EEPROM to increase endurance.
PIC16F628
defs_628.h - Header file which defines all SFR registers and bits.
_1_wire.c and _1_wire.h. Low level rotuines for interfacing with Dallas 1-wire devices.
1820_1.c - Interface with a Dallas DS1820 (DS18S20). Uses "Skip ROM"
to measure temperature.
ser_628.c and ser_628.h - A collection of RS232 routines using the
PIC's UART.
tst_ser2.c - Illustrates outputting data via UART to BasicX Serial LCD+ (or to standard terminal)
Low End Microchip PICs. PIC12C508/509/CE518/CE519, 16C505 and 16HV540, 12C671/672/CE673/CE674.
PIC18C452 - Debugged using an Advanced Transdata RICE-17A with a PB18 module.
defs_18c.h - Header file which defines all SFR registers and bits.
delay.c - delay_ms() and delay_10us() timing routines.
flash_1.c - Simple flashing of LED. Illustrates LATD.
ser_18c.c - A collection of RS232 routines using the PIC's UART.
tst_ser.c - Illustrates the use of the functions in ser_18c.c to output data to a terminal.
ad_1.c - Illustrates the use of the A/D converters.
pwm_1.c - Illustrates use of a CCP module configured for PWM.
pwm_2.c - The use of a potentiometer to control PWM duty.
rh_1.c - Measuring of relative humdity and temperature using a Honeywell HIH-3605 and a 10K NTC thermistor.
sw_clk.c - Illustrates switching between the main fosc and a 32.768 kHz crystal on T1OSC0 and T1OSC1.
tab_rd1.c - Illustrates saving compiler values of the table pointer and TABLAT and using TBLRD to read from memory.
tab_wt1.c - Extends on tab_rd1.c to illustrarte use of TBLWT.
rom_1.c - Illustrates how to efficiently use program memory for storing strings or .wav files.
rom_2.c - Illustrates how to read one of multiple strings from program memory.
mem_save.c - Saving and reading a float and a structure in program memory.
ext_int.c - Illustrates the use of external interrupts INT0, INT1 and INT2.
timer0_1.c - Use of Timer 0 in the 16-bit mode.
timer3_1.c - Use of Timer 3 to time for one second. Use of Timer 2 to beep a tone.
counter.c - Counts events on T13CKI for one second. Uses Timer 1 as the counter and Timer 3 to time for one second.
notes_1.c - Uses Timer3 / CCP2 in compare mode to alternately generate 440 and 500 Hz.
music_1.c - Plays a musical tune. Timer 1 / CCP1 is used to control the duration. Timer 3 / CCP2 to control the frequency.
step_1.c - Controls unipolar stepper motor. Uses Timer 1 with CCP1 in compare - trigger special event mode.
step_2.c - Stepper motor control - Illustrates acceleration and deceleration over a defined number of steps.
step_3.c - Controls motor using a potentiometer to determine direction and speed. Uses Timer 3 / CCP2 to periodically perfrom an A/D conversion and Timer 1 / CCP1 to control the time between outputting steps.
step_4.c - Similar to step_2.c except accelerates, decelerates and runs for a defined period of time. Uses Timer 3 / CCP2 for the duration of the timing and Timer 1 / CCP1 to control the time between outputting steps.
irrem_1.c - Captures transition times generated by a Sony TV remote control.
irrem_2.c - Decodes Sony TV remote to control the number of flashes of an LED (number keys), speed of the flash (volume control) and which LED is flashed (channel control).
irrem_3.c - Adds time out feature to the above using Timer 3.
li>25_640bb.c - Bit bang implementation of SPI. Interface with 25LC640
EEPROM.
25_640_1.c - Illustrates use of the SSP module in SPI mode. Interfaces with Microchip 25LC640 EEPROM, byte write and read.
25_640_2.c - Similar to 25_640_1.c except block write and read.
at45_1.c - Interface with an Atmel AT45DB321 4 Megabyte flash EEPROM. Illustrates buffer write and buufer read.
at45_2.c - Extends this to illustrate writing to one buffer, transferring that buffer to flash memory while writing to the second buffer, etc. The content of memory is then read and displayed to the terminal.
at45_3.c - Extends at45_2.c to perfrom A/D conversion at 1000 samples per second and save to the AT45DB321 and later read and display.
I will ill during the Summer, '02 and then with the pressures of school it has been some time sice the last distribution. I am hopeful I will have a good distribution in Sept, '03. My apologies.
For the next distribution. (Sept 1, '03)
PIC16F877 (Debugged using ICD 1)
ds1050_1.c - Dallas DS1050 PWM (I2C)
8-bit CRC using table lookup. Used with DS1820.
CRC16 using Table Lookup. Used with DS2450.
ds2450_1.c, Quad A/D, Dallas 1-W. Performs A/D conversion on all
channels.
ds2450_2.c - Performs A/D conversions on two channels and uses the
other channels as outputs.
tc3400.c - Interface with Microchip TC3400 16-bit sigma delta A/D.
PIC14000 (Debugged using EEPROM Version. PICStart Plus Programmer)
defs_14c.h - Header file which defines all SFR registers and bits.
ser_14c.h and ser_18c - Bit bang serial routines.
rd_cal1.c - Reads and displays calibration constants.
rd_cal2.c - Dummy routines to use during development.
admeas1.c - Performs 16-bit A/D conversion on specified channel and measures temperature inside the chip.
lo_meas.c - Illustrates A/D conversions using offset circuitry.
v_ref1.c - Illustrates voltage reference module to generate a specified voltage.
v_ref2.c - Extends this to measure the voltage reference and adjusts to provide the specified output.
i2c_slv3.c - Illustrates use of PIC14000 in I2C slave mode. Flashes LED specified number of times.
i2c_slv4.c - Extends to provide for either flash LED or perform an A/D conversion and send result to master. Also uses TMR0 to force slave to idle when invalid condition detected.
push_btn.c - Illustrates use of interrupt on transistion on OSC1 and toggles LED on OSC2.
PIC18F452 - These routines relate to data and flash EEPROM. Routines previously developed for the PIC18Cxx2, other than those related to FLASH EEPROM may be used on the flash version. (I think!). (Debugged using ICD 2).
ee_save.c - Illustrates how to write and read a float and a structure to data EEPROM.
eeprom_1.c - Illustrates the use of the data EEPROM. EEPROM location 0x00 is set to 100 on download. An LED is flashed while continually decrementing the EEPROM. When at zero, the program locks.
tble_rd1.c - Displays the first 256 bytes of flash program memory, the eight ID bytes, the configuration bytes at 0x30000 - 0x30000c and the device bytes at 0x3ffffe - 0x3fffff.
log1.c - Illustrates writing to flash EEPROM. Blocks of four bytes are sequentially written to flash eeprom and the data is then read and displayed on the terminal.
id_1.c - Illustrates writing and reading the ID bytes at 0x200000 - 0x200007.
config_1.c - Illustrates how to write to the configuration bytes. The watch dog timer configuration register is fetched, the prescale is modified and written back to the configuration byte.
PIC16F87xA (Debugged without emulator. Programmed using WARP-13A with RedBack 10A firmware). Note that this material focusues only on the differences between the PIC16F87x and the new PIC16F87xA devices.
defs877a.h - Defininitions of SFR registers and bits.
fl_ee.c - Illustrates writing to and reading from flash memory. (4-byte transfer).
vref1.c - Illustrates use of voltage reference module. Generates ramp on RA2, measures value using A/D and toggles LED on RE1.
vref2.c - Outputs specified value on RA2
cmp1.c - Illustrates the use of the comparator module in the 110 mode and the voltage reference module. Displays output states of the comparators.
cmp2.c - Expands on the above to illustrate the use of the comparator interrupt.
rc_1.c - Illustrates an arrangement to precisely measure an external RC using the comparator module, voltage reference module and timer1.