JAMAL JIMI
Member level 1
How to program the 14-bit wide configuration word in the PIC16F877 at location 2007h in the program memory........Can any one please give me the assembly example....???
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
__CONFIG _LVP_OFF & _DEBUG_OFF & _CP_OFF & _CPD_OFF & _BODEN_OFF & _WDT_OFF & _PWRTE_ON & _HS_OSC
Code ASM - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 ... ... ;========================================================================== ; ; Configuration Bits ; ; NAME Address ; CONFIG 2007h ; ;========================================================================== ; The following is an assignment of address values for all of the ; configuration registers for the purpose of table reads _CONFIG EQU H'2007' ;----- CONFIG Options -------------------------------------------------- _LP_OSC EQU H'3FFC' ; LP oscillator _XT_OSC EQU H'3FFD' ; XT oscillator _HS_OSC EQU H'3FFE' ; HS oscillator _RC_OSC EQU H'3FFF' ; RC oscillator _WDT_OFF EQU H'3FFB' ; WDT disabled _WDT_ON EQU H'3FFF' ; WDT enabled _PWRTE_ON EQU H'3FF7' ; PWRT enabled _PWRTE_OFF EQU H'3FFF' ; PWRT disabled _CP_All EQU H'0FCF' ; 0000h to 1FFFh code protected _CP_HALF EQU H'1FDF' ; 1000h to 1FFFh code protected _CP_UPPER_256 EQU H'2FEF' ; 1F00h to 1FFFh code protected _CP_OFF EQU H'3FFF' ; Code protection off _BODEN_OFF EQU H'3FBF' ; BOR disabled _BODEN_ON EQU H'3FFF' ; BOR enabled _LVP_OFF EQU H'3F7F' ; RB3 is digital I/O, HV on MCLR must be used for programming _LVP_ON EQU H'3FFF' ; RB3/PGM pin has PGM function; low-voltage programming enabled _CPD_ON EQU H'3EFF' ; Data EEPROM memory code-protected _CPD_OFF EQU H'3FFF' ; Code Protection off _WRT_ENABLE_OFF EQU H'3DFF' ; Unprotected program memory may not be written to by EECON control _WRT_ENABLE_ON EQU H'3FFF' ; Unprotected program memory may be written to by EECON control _DEBUG_ON EQU H'37FF' ; In-Circuit Debugger enabled, RB6 and RB7 are dedicated to the debugger _DEBUG_OFF EQU H'3FFF' ; In-Circuit Debugger disabled, RB6 and RB7 are general purpose I/O pins ... ...
; progam to flash all of PortB pins on and off every 4 seconds
; based on a 4 mhz crystal
list p=16f877
include p16f877.inc
__CONFIG _CP_OFF & _WDT_OFF & _XT_OSC & _PWRTE_ON & _LVP_OFF
cblock 0X20 ; specify user regiaters ( easier than EQU)
d1
d2
d3
COUNT
endc
org 0x000
GOTO Main
Main CLRF PORTB ; Set portb,c,d to digital outputs
CLRF PORTC
CLRF PORTD
BANKSEL TRISA
CLRF TRISB
CLRF TRISC
CLRF TRISD
BANKSEL 0
LOOP ; main program looP
CALL DELAY4s ; call this subrutine
MOVLW 0xFF
MOVWF PORTB ; Set port HIGH
CALL DELAY4s
MOVLW 0x00
MOVWF PORTB ; Set port LOW
GOTO LOOP
; SUBROUTINES
DELAY4s ; 4 SECOND DELAY
movlw 0x23
movwf d1
movlw 0xB9
movwf d2
movlw 0x09
movwf d3
Delay_0
decfsz d1, f
goto dly1
decfsz d2, f
dly1 goto dly2
decfsz d3, f
dly2 goto Delay_0
return
END ; END OF PROGRAM CODE
What is meant by the word 'EQU'.......I never used this word before...
4.27 equ – DEFINE AN ASSEMBLER CONSTANT
4.27.1 Syntax
label equ expr
4.27.2 Description
The value of expr is assigned to label.
4.27.3 Usage
This directive is used in the following types of code: absolute or relocatable. For
information on types of code, see Section 1.6 “Assembler Operation”.
In a single assembly file program, equ is commonly used to assign a variable name to
an address location in RAM. Do not use this method for assigning variables when
building a linked project; use a res directive inside a data section directive (idata, udata).
4.27.4 See Also
set cblock res idata udata udata_acs udata_ovr udata_shr
4.27.5 Simple Example
four equ 4 ; assigned the numeric value of 4 to label four
4.27.6 Application Example –set/equ
See this example under set