Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Error[126] Argument out of range (not a valid config for register address)

Status
Not open for further replies.

brucewayne

Newbie level 3
Joined
Jun 5, 2012
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,301
My pic is 16f877a. Here is my code
list p=16f877a ; locates the processor file
#include <p16f877a.inc> ; defines variables inside processor
;__config _CP_OFF & _DEBUG_OFF & _LVP_OFF & _BODEN_ON & _WDT_OFF & _HS_OSC & _PWRTE_ON
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _HS_OSC & _WRT_ENABLE_ON & _LVP_OFF & _DEBUG_OFF & _CPD_OFF

errorlevel 0,-302


; MEMORY LOCATIONS
;************************************************************

Buffer EQU 0x20
DelayX EQU 0x21
DelayY EQU 0x22
DelayZ EQU 0x23
Reg1 EQU 0x24
Reg2 EQU 0x25
d_a EQU 0x26
d_b EQU 0x27
d_c EQU 0x28


;************************************************************
; Vectors for RESET, INTERRUPT

ORG 0x0000 ;Reset Vector
GOTO Start

ORG 0x0004 ;Interrupt vector
GOTO InterruptVector


;Initial program begins here


Start
CLRF PIR1
CLRF PIR2 ;Clear interrupt flags registers

BSF STATUS, RP0 ; Set RAM Bank 1
MOVLW .7
MOVWF ADCON1 ;PortA and PortE all digital I/O
CLRF TRISB ;Port B all outputs
CLRF TRISC ;Port C all outputs
CLRF TRISD ;Port D all outputs
CLRF TRISE
CLRF TXSTA
CLRF PIE1
BCF STATUS, RP0
CLRF ADCON0
CLRF RCSTA
CLRF INTCON ;Port E all outputs
movlw H'01' ; Clock is connected to PORTB,0. Assign to Reg1,0 (current value of clock)
andwf PORTB,W
movwf Reg1
clrf Reg2

;***********************************************************

MnLoop

;Initialising LCD Display
BCF PORTE, 1 ;Set The LCD to Read only

;LED power up sequence

BCF PORTE, 0 ;Instruction register select
MOVLW .25
CALL Delay ;Delay for LCD PowerUp
MOVLW .30
CALL WrLCD ;Set LCD to 8 bits
MOVLW .5
CALL Delay ;Delay for LCD
MOVLW .30
CALL WrLCD ;Set LCD to 8 bits
MOVLW .5
CALL Delay ;Delay for LCD
MOVLW .30
CALL WrLCD ;Set LCD to 8 bits
MOVLW .5
CALL Delay ;Delay for LCD
MOVLW .56
CALL WrLCD ;8 bit interface 2 line, 5x7 character format
MOVLW .5
CALL Delay ;Delay for LCD
MOVLW .56
CALL WrLCD ;8 bit interface 2 line, 5x7 character format
MOVLW .5
CALL Delay ;Delay for LCD

;Input user specific config data

MOVLW .6
CALL WrLCD ;Display shifting disabled, use cursor shifting instead
MOVLW .5
CALL Delay ;Delay for LCD
MOVLW .1
CALL WrLCD ;Clear all DDRAM and set cursor to pos 1
MOVLW .5
CALL Delay ;Delay for LCD
MOVLW .15
CALL WrLCD ;Display On & show cursor blinking with an underline
BSF PORTE, 0 ;Set to data register

UPDATE_LCD

;Input data on LCD " Student ID and Traffic Lights"

MOVLW 'S'
CALL WrLCD
MOVLW '/'
CALL WrLCD
MOVLW 'N'
CALL WrLCD
MOVLW ':'
CALL WrLCD
MOVLW '1'
CALL WrLCD
MOVLW '1'
CALL WrLCD
MOVLW '4'
CALL WrLCD
MOVLW '5'
CALL WrLCD
MOVLW '9'
CALL WrLCD
MOVLW '7'
CALL WrLCD
MOVLW '9'
CALL WrLCD
MOVLW '1'
CALL WrLCD


;Move to second line of LCD - "Traffic Lights"

BCF PORTE, 0 ;Set instruction register
MOVLW .197
CALL WrLCD
BSF PORTE, 0 ;Set data register

; Put data onto the second line - "Traffic Light Signals"


MOVLW 'G'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW 'R'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW '6'
CALL WrLCD
BSF PORTA,0
BSF PORTA,1
BSF PORTA,2
BSF PORTA,3

BCF PORTE, 0
MOVLW .197
CALL WrLCD
CALL CurrentPrevious
CALL CheckRisingEdge
BTFSS Reg2,0
CALL $-3
nop
BSF PORTE, 0


MOVLW 'G'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW 'R'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW '5'
CALL WrLCD
BSF PORTA,0
BSF PORTA,1
BSF PORTA,2
BCF PORTA,3

BCF PORTE, 0
MOVLW .197
CALL WrLCD
CALL CurrentPrevious
CALL CheckRisingEdge
BTFSS Reg2,0
CALL $-3
nop
BSF PORTE, 0



MOVLW 'G'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW 'R'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW '4'
CALL WrLCD
BSF PORTA,0
BSF PORTA,1
BCF PORTA,2
BCF PORTA,3

BCF PORTE, 0
MOVLW .197
CALL WrLCD
CALL CurrentPrevious
CALL CheckRisingEdge
BTFSS Reg2,0
CALL $-3
nop
BSF PORTE, 0


MOVLW 'G'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW 'R'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW '3'
CALL WrLCD
BSF PORTA,0
BCF PORTA,1
BCF PORTA,2
BSF PORTA,3

BCF PORTE, 0
MOVLW .197
CALL WrLCD
CALL CurrentPrevious
CALL CheckRisingEdge
BTFSS Reg2,0
CALL $-3
nop
BSF PORTE, 0


MOVLW 'G'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW 'R'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW '2'
CALL WrLCD
BSF PORTA,0
BCF PORTA,1
BCF PORTA,2
BCF PORTA,3

BCF PORTE, 0
MOVLW .197
CALL WrLCD
CALL CurrentPrevious
CALL CheckRisingEdge
BTFSS Reg2,0
CALL $-3
nop
BSF PORTE, 0


MOVLW 'G'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW 'R'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW '1'
CALL WrLCD
BSF PORTA,0
BCF PORTA,1
BCF PORTA,2
BCF PORTA,3

BCF PORTE, 0
MOVLW .197
CALL WrLCD
CALL New_Delay1
BSF PORTE, 0


MOVLW 'Y'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW 'R'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW '0'
CALL WrLCD
BSF PORTA,0
BCF PORTA,1
BSF PORTA,2
BCF PORTA,3

BCF PORTE, 0
MOVLW .197
CALL WrLCD
CALL CurrentPrevious
CALL CheckRisingEdge
BTFSS Reg2,0
CALL $-3
nop
BSF PORTE, 0


MOVLW 'R'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW 'R'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW '0'
CALL WrLCD
BSF PORTA,0
BCF PORTA,1
BSF PORTA,2
BSF PORTA,3


BCF PORTE, 0
MOVLW .197
CALL WrLCD
CALL New_Delay1
BSF PORTE, 0


MOVLW 'R'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW 'G'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW '6'
CALL WrLCD
BCF PORTA,0
BCF PORTA,1
BSF PORTA,2
BSF PORTA,3

BCF PORTE, 0
MOVLW .197
CALL WrLCD
CALL CurrentPrevious
CALL CheckRisingEdge
BTFSS Reg2,0
CALL $-3
nop
BSF PORTE, 0


MOVLW 'R'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW 'G'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW '5'
CALL WrLCD
BCF PORTA,0
BCF PORTA,1
BSF PORTA,2
BCF PORTA,3

BCF PORTE, 0
MOVLW .197
CALL WrLCD
CALL CurrentPrevious
CALL CheckRisingEdge
BTFSS Reg2,0
CALL $-3
nop
BSF PORTE, 0


MOVLW 'R'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW 'G'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW '4'
CALL WrLCD
BCF PORTA,0
BCF PORTA,1
BCF PORTA,2
BCF PORTA,3

BCF PORTE, 0
MOVLW .197
CALL WrLCD
CALL CurrentPrevious
CALL CheckRisingEdge
BTFSS Reg2,0
CALL $-3
nop
BSF PORTE, 0


MOVLW 'R'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW 'G'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW '3'
CALL WrLCD
BCF PORTA,0
BCF PORTA,1
BCF PORTA,2
BSF PORTA,3

BCF PORTE, 0
MOVLW .197
CALL WrLCD
CALL CurrentPrevious
CALL CheckRisingEdge
BTFSS Reg2,0
CALL $-3
nop
BSF PORTE, 0


MOVLW 'R'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW 'G'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW '2'
CALL WrLCD
BCF PORTA,0
BSF PORTA,1
BCF PORTA,2
BSF PORTA,3

BCF PORTE, 0
MOVLW .197
CALL WrLCD
CALL CurrentPrevious
CALL CheckRisingEdge
BTFSS Reg2,0
CALL $-3
nop
BSF PORTE, 0


MOVLW 'R'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW 'G'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW '1'
CALL WrLCD
BCF PORTA,0
BSF PORTA,1
BCF PORTA,2
BCF PORTA,3

BCF PORTE, 0
MOVLW .197
CALL WrLCD
CALL CurrentPrevious
CALL CheckRisingEdge
BTFSS Reg2,0
CALL $-3
nop
BSF PORTE, 0


MOVLW 'R'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW 'Y'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW '0'
CALL WrLCD
BCF PORTA,0
BSF PORTA,1
BSF PORTA,2
BCF PORTA,3

BCF PORTE, 0
MOVLW .197
CALL WrLCD
CALL CurrentPrevious
CALL CheckRisingEdge
BTFSS Reg2,0
CALL $-3
nop
BSF PORTE, 0


MOVLW 'R'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW 'R'
CALL WrLCD
MOVLW ' '
CALL WrLCD
MOVLW '0'
CALL WrLCD
BCF PORTA,0
BSF PORTA,1
BSF PORTA,2
BSF PORTA,3

;Write to second line of LCD

BCF PORTE, 0
MOVLW .207
CALL WrLCD
call CurrentPrevious
call CheckRisingEdge
btfsc Reg2, 0
CALL $-3
nop
BSF PORTE, 0 ; Set data register




Wait ; Infinite Loop
GOTO MnLoop ; loop to self doing nothing


;End of Main Loop

;************************************************************
;Subroutines for writing to LCD

WrLCD ;Write to the LCD in 8 bit mode

MOVWF Buffer ;Temporarily store data to be written to the LCD
BCF PORTE, 2 ;Clear the enable pin
MOVLW .1
CALL Delay ;1ms Delay for LCD timing
MOVF Buffer, W
MOVWF PORTD ;Write stored data to PORTD ie LCD data pins
BSF PORTE, 2 ;Pulse Enable pin
NOP
BCF PORTE, 2
RETURN


CurrentPrevious

movf Reg1, F ; move the previous reading to reg1,1 and put the new one in Reg1,0
movlw H'01' ; Assign clock to Reg1,0
andwf PORTB,W
iorwf Reg1,F
movlw H'03'
andwf Reg1,f
return

CheckRisingEdge

btfsc Reg1,1
goto NoRisingEdge
btfss Reg1,0
goto NoRisingEdge
bsf Reg2,0 ; Rising edge
return

NoRisingEdge

bcf Reg2,0 ; No rising edge
return


New_Delay1 ;Delay for 2s, count cycles based on 20Mhz clock

MOVLW 0x5A
MOVWF d_a
MOVLW 0xCD
MOVWF d_b
MOVLW 0x16
MOVWF d_c


New_Delay2 ;Delay for some ms, count cycles based on 20Mhz clock

DECFSZ d_a, f
GOTO $+2
DECFSZ d_b, f
GOTO $+2
DECFSZ d_c, f
GOTO New_Delay2

; One complete cycle

NOP



Delay ;Delay for some ms, count cycles based on 20Mhz clock
MOVWF DelayX
OutLoop
MOVLW .29
MOVWF DelayY
MidLoop
MOVLW .42
MOVWF DelayZ
InLoop
NOP
DECFSZ DelayZ, F
GOTO InLoop
DECFSZ DelayY, F
GOTO MidLoop
DECFSZ DelayX, F
GOTO OutLoop
RETURN




;************************************************************
; Interrupt Service Routine

InterruptVector ; Empty the vector in case
RETFIE ; finish interrupt and return

END
 

Hi,

The WTR is for write protect of some all all of the EEPROM, the " _ENABLE_ON " is not a valid option.
You would normally use _OFF as you normally want to write to all EEprom.

Full details of the options are given in the MPASM/Includes/16f877a.inc file.

You will also find your register names d_a,b &c are invalid, just change them to something else.

Your code has very few comments to clearly show what ports and pins are being use for the hardware, eg lcd, its also such a lot of code, again without comments it means trying to go though it all is not easy.

If you can suply a ciruit diagram / pinout I could try it in a simulator to see how it runs

Edit

You might also find this good tutorial of help with these examples on the Usart and LCD

http://www.winpicprog.co.uk/pic_tutorial7.htm download and see the code examples and see #7.7 which is the hardware Usart for the 876/877 chips.

http://www.winpicprog.co.uk/pic_tutorial3.htm
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top