 |
| Experiment 2. Input & Output on Port A |
|
|
|
|
|
|
| The Experiment 2 we will test Port A is both Input and Output . Assemble circuit as figure 2.1 and Download Program to PIC16F628 |
| |
|
|
Figure 2.1 schematic for Experiment 2 Input & Output on Port A |
Assemble circuit as figure 2.1 and Down load Programming to PIC16F628 |
|
 |
| Source Code For Experiment 2 |
|
|
|
|
|
|
| list p=16f628 |
; list directive to define processor |
| #include <p16f628.inc> |
; processor specific variable definitions |
|
|
|
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _XT_OSC & _MCLRE_ON & _LVP_OFF |
|
|
|
| org |
0x000 |
|
| clrf |
PORTA |
; Initial POR TA |
|
|
; output data latches |
| movlw |
0x07 |
; Turn Comparator off and |
| movwf |
CMCON |
; Enable pins for I/O |
| bsf |
STATUS,RP0 |
; Select Bank 1 |
| movlw |
b'11111111' |
; All PORTA = Input |
| movwf |
PORTA |
; |
| bcf |
STATUS,RP0 |
; Return to Bank 0 |
| btfsc |
PORTA,0 |
; Test Switch Press ? |
| goto |
$-1 |
; If Not Press Loop |
| bsf |
STATUS,RP0 |
; If Press Set RA0 = Output |
| bcf |
PORTA,0 |
; TRISA |
| bcf |
STATUS,RP0 |
; Return To Bank 0 |
| bcf |
PORTA,0 |
; RA0 = 0 LED "ON" |
| goto |
$ |
|
| END |
; end of program' |
|
|
|
From The Source Code we can be explain by flowchart as figure 2.2 |
|
|
|
|
Figure 2.2 Flowchart of Experiment 2 |
|
|
|
|
|
| |
Name List |
Quantity |
MPLAB |
- |
PIC16F628 |
1 |
4 MHz Crystal |
1 |
LED |
1 |
Push Button Switch 1 PC |
2 |
33 pF Capacitors |
2 |
4.7K Resistors |
1 |
1K Resistors |
1 |
|
|
|
|
|
|
|
|
|
|
|
| Resources ,Tools & Related |
|
|
|
|
|
|
|
|