pickit3 18F45K20with assembly

Thread Starter

Nico Benakis

Joined Dec 18, 2015
2
Hello there,i got my pickit3 with 18F45k20 44-pin demo board .I was trying about two weeks to figure out what is going on with the configure template code in MPLAB v8.92 in assembly language.First of all i start the project wizard ,i put in the source files the file "18f45k20TEMP.ASM " file and in Linker script the file called " 18f45k20_g.lkr " .Without changes in the code i press BUILD ALL and i get some errors like

Error[115] C:\USERS\NICKOLAS\DESKTOP\ATOD\18F45K20TEMP.ASM 148 : Duplicate label ("START" or redefining symbol that cannot be redefined)
Error[113] C:\USERS\NICKOLAS\DESKTOP\ATOD\18F45K20TEMP.ASM 150 : Symbol not previously defined (RP0)
Error[113] C:\USERS\NICKOLAS\DESKTOP\ATOD\18F45K20TEMP.ASM 152 : Symbol not previously defined (RP0)

i send you a picture to see clearly... --> http://prntscr.com/9hblv7

i cant figure out what is going on with this pic...and i wanna get started with simple projects such as flash led ,analog to digital e.t.c
i think the main ISSUE is the configure template,if i fix that everything will run ...the problem is that i cant understand what its going on.
i will send you the full code and template to see .... Please help me guys if anyone knows something for this...Thanks for your time !

Code:
     LIST      P=PIC18F45K20          ; list directive to define processor
     #INCLUDE <P18F45K20.INC>         ; processor specific variable definitions

;------------------------------------------------------------------------------
;
; CONFIGURATION WORD SETUP
;
; The 'CONFIG' directive is used to embed the configuration word within the
; .asm file. The lables following the directive are located in the respective
; .inc file.  See the data sheet for additional information on configuration
; word settings.
;
;------------------------------------------------------------------------------

     CONFIG FOSC = INTIO7, FCMEN = OFF, IESO = OFF, PWRT = OFF, BOREN = OFF
     CONFIG BORV = 18, WDTEN = OFF, WDTPS = 1, MCLRE = ON, HFOFST = ON
     CONFIG LPT1OSC = OFF, PBADEN = OFF, CCP2MX = PORTC, STVREN = OFF
     CONFIG LVP = OFF,  XINST = OFF, CP0 = OFF, CP1 = OFF, CP2 = OFF
     CONFIG CP3 = OFF, CPB = OFF, CPD = OFF, WRT0 = OFF, WRT1 = OFF
     CONFIG WRT2 = OFF, WRT3 = OFF, WRTB = OFF, WRTC = OFF, WRTD = OFF
     CONFIG EBTR0 = OFF, EBTR1 = OFF, EBTR2 = OFF, EBTR3 = OFF
     CONFIG EBTRB = OFF

;------------------------------------------------------------------------------
;
; VARIABLE DEFINITIONS
;
;------------------------------------------------------------------------------

    CBLOCK 0x60 ; Sample GPR variable register allocations
        MYVAR1  ; user variable at address 0x60
        MYVAR2  ; user variable at address 0x61
        MYVAR3  ; user variable at address 0x62
    ENDC
   


W_TEMP         EQU        0x000  ; w register for context saving (ACCESS)
STATUS_TEMP    EQU        0x001  ; status used for context saving
BSR_TEMP       EQU        0x002  ; bank select used for ISR context saving

;------------------------------------------------------------------------------
; EEPROM INITIALIZATION
;
; The 18F45K20 has non-volatile EEPROM starting at 0xF00000
;
;------------------------------------------------------------------------------

DATAEE    ORG  0xF00000 ; Starting address for EEPROM for 18F45K20

    DE    "MCHP"        ; Place 'M' 'C' 'H' 'P' at address 0,1,2,3

;------------------------------------------------------------------------------
; RESET VECTOR
;------------------------------------------------------------------------------

RES_VECT  ORG     0x0000            ; processor reset vector
                       ; go to beginning of program

;------------------------------------------------------------------------------
; HIGH PRIORITY INTERRUPT VECTOR
;------------------------------------------------------------------------------

ISRH      ORG     0x0008

          ; Run the High Priority Interrupt Service Routine
          GOTO    HIGH_ISR            

;------------------------------------------------------------------------------
; LOW PRIORITY INTERRUPT VECTOR
;------------------------------------------------------------------------------

ISRL      ORG     0x0018
         
          ; Run the High Priority Interrupt Service Routine
          GOTO    LOW_ISR            

;------------------------------------------------------------------------------
; HIGH PRIORITY INTERRUPT SERVICE ROUTINE
;------------------------------------------------------------------------------

HIGH_ISR 

          ; Insert High Priority ISR Here

          RETFIE  FAST

;------------------------------------------------------------------------------
; LOW PRIORITY INTERRUPT SERVICE ROUTINE
;------------------------------------------------------------------------------

LOW_ISR
          ; Context Saving for Low ISR
          MOVWF   W_TEMP              ; save W register
          MOVFF   STATUS, STATUS_TEMP ; save status register
          MOVFF   BSR, BSR_TEMP       ; save bankselect register

          ; Insert Low Priority ISR Here

          ; Context Saving for Low ISR
          MOVFF   BSR_TEMP, BSR       ; restore bankselect register
          MOVF    W_TEMP, W           ; restore W register
          MOVFF   STATUS_TEMP, STATUS ; restore status register
          RETFIE

;------------------------------------------------------------------------------
; MAIN PROGRAM
;------------------------------------------------------------------------------

START

       BSF STATUS,RP0 ; select Register Bank 1
BCF TRISD,0 ; make IO Pin RD0 an output
BCF STATUS,RP0 ; back to Register Bank 0
BSF PORTD,0 ; turn on LED RD0 (DS0)
  GOTO $                      ; loop program counter
END
 

Attachments

atferrari

Joined Jan 6, 2004
4,764
Error[115] C:\USERS\NICKOLAS\DESKTOP\ATOD\18F45K20TEMP.ASM 148 : Duplicate label ("START" or redefining symbol that cannot be redefined)
Hola Niko,

The reason is painfully obvious (Max knew that!). It is staring at you in your face.

Code:
   #INCLUDE P18F45K20.INC         ; processor specific variable definitions
Your (simple) code offers one sole possibility: the content of the .inc file which is actually forming part of your code.

If you search inside (Ctrl F) you get this:

Here is way.png

Next time, please, just double click on the error line and it should bring you to the offending lines, otherwise use the "Find in files" option.

Buena suerte.
 

MaxHeadRoom

Joined Jul 18, 2013
28,617
Agustín nailed it!
Although not really good practice, if you want to use a label and you are not sure if it has already been designated in the INC file etc, you could use lower case, for e.g. Start instead of START.
Max.
 

JohnInTX

Joined Jun 26, 2012
4,787
Agustín nailed it!
Although not really good practice, if you want to use a label and you are not sure if it has already been designated in the INC file etc, you could use lower case, for e.g. Start instead of START.
Max.
Personally, I would not do that. You can turn MPASM case sensitivity on and off in Project Properties. If you lost track of the project setting you'd have problems. In the best case, you would have duplicate symbols again. In the worst case, you could have macros that ceased to expand correctly and that's only an easy to miss warning, not an error that would force a look-see. Moving a project to a different computer, MPLAB version or programmer could easily foul things up. MikroC is another one to watch. Case sensitivity is OFF by default - not really C.

The way I beat this is to preface symbols with the module's function i.e START would become I2C_START etc.
 
Top