please write the code based on code below #include \"p16F18875.inc“ ; Set PIC16F
ID: 2084768 • Letter: P
Question
please write the code based on code below
#include "p16F18875.inc“
; Set PIC16F18875 Configuration Bit Settings (do NOT change)
__CONFIG _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT1 & _CLKOUTEN_OFF & _CSWEN_ON & _FCMEN_ON
__CONFIG _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_ON & _STVREN_ON
__CONFIG _CONFIG3, _WDTCPS_WDTCPS_31 & _WDTE_OFF & _WDTCWS_WDTCWS_7 & _WDTCCS_SC
__CONFIG _CONFIG4, _WRT_OFF & _SCANE_available & _LVP_ON
__CONFIG _CONFIG5, _CP_OFF & _CPD_OFF
; Insert local 'equivalent' statements
out_cnt equ 0x20
mid_cnt equ 0x21
inn_cnt equ 0x22
cnt equ 0x23
; Define origin of program code
org 0x000
nop
; setup the clock to 4MHz - do not change unless you want to change the clock
banksel OSCCON1
movlw 0x60
movwf OSCCON1
banksel PORTA
clrf PORTA
clrf LATA
clrf TRISA
bcf PORTC,5
bcf LATC,5
bsf TRISC,5
banksel ANSELA
clrf ANSELA
clrf ANSELC
banksel PORTA
MAIN:
bsf PORTA, 6
call SPD_CHECK
call DELAY
bcf PORTA,6
bsf PORTA,5
call SPD_CHECK
call DELAY
bcf PORTA,5
bsf PORTA,4
call SPD_CHECK
call DELAY
bcf PORTA,4
bsf PORTA,5
call SPD_CHECK
call DELAY
bcf PORTA,5
I/O and Timing Loops +-' RA7 RA6 RAS r RA0 RB4 4 10 Figure I. The developrnent board's four LED. PURPOSE: The development board has 4 Light Emitting Diodes (LEDs). In Lab #2 we will use three of those: the LEDs connected to digital I/O pins RA4, RA5, and RA6 (they are labelled as such on the development board and shown in Figure 1). In addition, we will also use one of the two push buttons: S2 connected to digital I/O pin RCS (see Figure 1). +' PURPOSE OF THIS LAB:J Design and write a program that implements the following two high-level software requirements: ~' HIA: The progran shall turn on the three LEDs, one at a time, for T = 1 seconds following the pattern: RA4 ON Others OFF RA5 ON Others OFF RA6 ON Others OFF RA5 ON Others OFF HL-2: The program shall read the input from push-button S2 (either a "O" or a "1") and change T to 0.5 seconds while the push-button is pushed, and back to T = 1 second when the push-button is not pushedExplanation / Answer
complete program for the given PIC controller
#include "p16F18875.inc“
PIC16F18875
__CONFIG _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT1 & _CLKOUTEN_OFF & _CSWEN_ON & _FCMEN_ON
__CONFIG _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_ON & _STVREN_ON
__CONFIG _CONFIG3, _WDTCPS_WDTCPS_31 & _WDTE_OFF & _WDTCWS_WDTCWS_7 & _WDTCCS_SC
__CONFIG _CONFIG4, _WRT_OFF & _SCANE_available & _LVP_ON
__CONFIG _CONFIG5, _CP_OFF & _CPD_OFF
out_cnt equ 0x20
mid_cnt equ 0x21
inn_cnt equ 0x22
cnt equ 0x23
org 0x000
nop
clock 4MHz
banksel OSCCON1
movlw 0x60
movwf OSCCON1
banksel PORTA
clrf PORTA
clrf LATA
clrf TRISA
bcf PORTC,5
bcf LATC,5
bsf TRISC,5
banksel ANSELA
clrf ANSELA
clrf ANSELC
banksel PORTA
bsf PORTA, 6
call SPD_CHECK
call DELAY
bcf PORTA,6
bsf PORTA,5
call SPD_CHECK
call DELAY
bcf PORTA,5
bsf PORTA,4
call SPD_CHECK
call DELAY
bcf PORTA,4
bsf PORTA,5
call SPD_CHECK
call DELAY
bcf PORTA,5
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.