Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

PicBasic Experiments With The PIC16F877

This page is for reference while working through the PIC16F877 experiments.
Figure 1 shows the connections for using an LCD with the PIC16F877 experiments. Use this diagram to connect your LCD to the PIC16F877. The display is useful while following along with these experiments. The LCD helps in the debugging process if something doesn't work quite right the first time, and is used to display the results when everything goes according to plan. Note: Be sure to use a 4 MHz oscillator since the sample code has been written assuming you're using a 4 MHz ceramic oscillator or 4 MHz crystal. Using up to 20 MHz oscillators is easy to do with PicBasic and the PIC16F877, but you must include the DEFINE OSC 20 command to inform PicBasic that your timing requirements are different than the default 4 MHz mode. Figure 2 is the pin diagram for the PIC16F877 microcontroller. Figure 3 shows how to connect either a ceramic resonator, or a quartz crystal for the experiments.

Figure 1: Basic LCD hookup diagram for all experiments with the PIC16F877.

LCD Pin Descriptions: Pin # 1 = Vss (LCD GND) Pin # 2 = Vdd (LCD +5V) Pin # 3 = Vo (LCD contrast adjust input) Pin # 4 = RS (LCD register select) Pin # 5 = R/W (LCD read/write input) Pin # 6 = E (LCD enable) Pin # 7 = DB0 (LCD data-input 0) Pin # 8 = DB1 (LCD data-input 1) Pin # 9 = DB2 (LCD data-input 2) Pin # 10 = DB3 (LCD data-input 3) Pin # 11 = DB4 (LCD data-input 4) Pin # 12 = DB5 (LCD data-input 5) Pin # 13 = DB6 (LCD data-input 6) Pin # 14 = DB7 (LCD data-input 7) The LCD is used in 4-Bit Mode for these experiments (unless otherwise specified), so the data-inputs DB0-DB3 are not used.

Figure 2: PIC16F877 Pin Diagram. Figure 3 shows how to connect both oscillator options. Using a ceramic resonator is normally less expensive, and requires fewer components since the ceramic resonator has internal capacitors to complete the oscillator circuit. Note: If you order ceramic resonators, make sure you get them with internal capacitors. There are versions that don't include them. The Digi-Key part number for 4MHz ceramic resonators (with internal capacitors) is: X902. They cost approximately 68 cents each in single quantitie

Figure 3: Oscillator Options for the PIC16F877 experiments. If you're new to using ceramic resonators, the center-pin of the resonator is ground. There has been some discussion as to whether or not resonators are adequate for applications requiring high-speed serial communications, but I'll leave that one up to you to find out. For further study, I highly recommend you take a peek at the Fox Electronics web site at: http://www.foxonline.com/ They have some outstanding articles explaining oscillator theory, and even some info on ceramic resonators vs. crystals. If you're an engineer, and concerned about whether or not to use resonators in your next design, the time you spend at the Fox web site will be well worthwhile. We use ceramic resonators in 99.9% of all our PIC based designs, and have yet to experience any problems. That, however, is an entirely different discussion, and we're not here for that purpose. It's best that you investigate this on your own. For these particular experiments, either oscillator option will work just fine....;o] If you don't have PicBasic yet, we have that here as well. Click HERE for details on how to get your own copy of PicBasic, or PicBasic Pro. We have complete programming packages available at very reasonable prices. NOTE: Use your browsers BACK BUTTON to return to the experiments page you were on before, or click HERE to return to the PicBasic Projects Page.

You might also like