Tuesday, January 5

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



Source Code For Experiment 2

list p=16f628 ; list directive to define processor
#include ; 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'




Tools & Components


Name List Quantity
MPLAB -
PIC16F628 1
4MHz Crystal 1
LED 1

Push Button Switch 1 PC 2
33pF Capacitors 2
4.7K Resistors 1
1K Resistors 1

No comments:

Post a Comment