pickit3 18F45K20with assembly

Discussion in 'Embedded Systems and Microcontrollers' started by Nico Benakis, Dec 22, 2015.

  1. Nico Benakis

    Thread Starter New Member

    Dec 18, 2015
    2
    0
    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 (Text):
    1.  
    2.      LIST      P=PIC18F45K20          ; list directive to define processor
    3.      #INCLUDE <P18F45K20.INC>         ; processor specific variable definitions
    4.  
    5. ;------------------------------------------------------------------------------
    6. ;
    7. ; CONFIGURATION WORD SETUP
    8. ;
    9. ; The 'CONFIG' directive is used to embed the configuration word within the
    10. ; .asm file. The lables following the directive are located in the respective
    11. ; .inc file.  See the data sheet for additional information on configuration
    12. ; word settings.
    13. ;
    14. ;------------------------------------------------------------------------------
    15.  
    16.      CONFIG FOSC = INTIO7, FCMEN = OFF, IESO = OFF, PWRT = OFF, BOREN = OFF
    17.      CONFIG BORV = 18, WDTEN = OFF, WDTPS = 1, MCLRE = ON, HFOFST = ON
    18.      CONFIG LPT1OSC = OFF, PBADEN = OFF, CCP2MX = PORTC, STVREN = OFF
    19.      CONFIG LVP = OFF,  XINST = OFF, CP0 = OFF, CP1 = OFF, CP2 = OFF
    20.      CONFIG CP3 = OFF, CPB = OFF, CPD = OFF, WRT0 = OFF, WRT1 = OFF
    21.      CONFIG WRT2 = OFF, WRT3 = OFF, WRTB = OFF, WRTC = OFF, WRTD = OFF
    22.      CONFIG EBTR0 = OFF, EBTR1 = OFF, EBTR2 = OFF, EBTR3 = OFF
    23.      CONFIG EBTRB = OFF
    24.  
    25. ;------------------------------------------------------------------------------
    26. ;
    27. ; VARIABLE DEFINITIONS
    28. ;
    29. ;------------------------------------------------------------------------------
    30.  
    31.     CBLOCK 0x60 ; Sample GPR variable register allocations
    32.         MYVAR1  ; user variable at address 0x60
    33.         MYVAR2  ; user variable at address 0x61
    34.         MYVAR3  ; user variable at address 0x62
    35.     ENDC
    36.    
    37.  
    38.  
    39. W_TEMP         EQU        0x000  ; w register for context saving (ACCESS)
    40. STATUS_TEMP    EQU        0x001  ; status used for context saving
    41. BSR_TEMP       EQU        0x002  ; bank select used for ISR context saving
    42.  
    43. ;------------------------------------------------------------------------------
    44. ; EEPROM INITIALIZATION
    45. ;
    46. ; The 18F45K20 has non-volatile EEPROM starting at 0xF00000
    47. ;
    48. ;------------------------------------------------------------------------------
    49.  
    50. DATAEE    ORG  0xF00000 ; Starting address for EEPROM for 18F45K20
    51.  
    52.     DE    "MCHP"        ; Place 'M' 'C' 'H' 'P' at address 0,1,2,3
    53.  
    54. ;------------------------------------------------------------------------------
    55. ; RESET VECTOR
    56. ;------------------------------------------------------------------------------
    57.  
    58. RES_VECT  ORG     0x0000            ; processor reset vector
    59.                        ; go to beginning of program
    60.  
    61. ;------------------------------------------------------------------------------
    62. ; HIGH PRIORITY INTERRUPT VECTOR
    63. ;------------------------------------------------------------------------------
    64.  
    65. ISRH      ORG     0x0008
    66.  
    67.           ; Run the High Priority Interrupt Service Routine
    68.           GOTO    HIGH_ISR            
    69.  
    70. ;------------------------------------------------------------------------------
    71. ; LOW PRIORITY INTERRUPT VECTOR
    72. ;------------------------------------------------------------------------------
    73.  
    74. ISRL      ORG     0x0018
    75.          
    76.           ; Run the High Priority Interrupt Service Routine
    77.           GOTO    LOW_ISR            
    78.  
    79. ;------------------------------------------------------------------------------
    80. ; HIGH PRIORITY INTERRUPT SERVICE ROUTINE
    81. ;------------------------------------------------------------------------------
    82.  
    83. HIGH_ISR
    84.  
    85.           ; Insert High Priority ISR Here
    86.  
    87.           RETFIE  FAST
    88.  
    89. ;------------------------------------------------------------------------------
    90. ; LOW PRIORITY INTERRUPT SERVICE ROUTINE
    91. ;------------------------------------------------------------------------------
    92.  
    93. LOW_ISR
    94.           ; Context Saving for Low ISR
    95.           MOVWF   W_TEMP              ; save W register
    96.           MOVFF   STATUS, STATUS_TEMP ; save status register
    97.           MOVFF   BSR, BSR_TEMP       ; save bankselect register
    98.  
    99.           ; Insert Low Priority ISR Here
    100.  
    101.           ; Context Saving for Low ISR
    102.           MOVFF   BSR_TEMP, BSR       ; restore bankselect register
    103.           MOVF    W_TEMP, W           ; restore W register
    104.           MOVFF   STATUS_TEMP, STATUS ; restore status register
    105.           RETFIE
    106.  
    107. ;------------------------------------------------------------------------------
    108. ; MAIN PROGRAM
    109. ;------------------------------------------------------------------------------
    110.  
    111. START
    112.  
    113.        BSF STATUS,RP0 ; select Register Bank 1
    114. BCF TRISD,0 ; make IO Pin RD0 an output
    115. BCF STATUS,RP0 ; back to Register Bank 0
    116. BSF PORTD,0 ; turn on LED RD0 (DS0)
    117.   GOTO $                      ; loop program counter
    118. END
     
  2. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,571
    2,382
    You do not use page switching in the 18F series.
    The Start label must be duplicated somewhere.
    Max.
     
    atferrari and Nico Benakis like this.
  3. Nico Benakis

    Thread Starter New Member

    Dec 18, 2015
    2
    0
    First of all thanks for the answer,secondly how can i fix this? I am beginner with assembly code
     
  4. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,571
    2,382
    Eliminate lines 113, 115 , do a search for START. Should only turn up once as a label.
    Max.
     
  5. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,571
    2,382
    If you down load the MPASM Assembler User Guide it shows what the error numbers mean, e.g. [113] [115] etc.
    Max.
     
  6. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,653
    768
    Hola Niko,

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

    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 likes this.
  7. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,571
    2,382
    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.
     
  8. JohnInTX

    Moderator

    Jun 26, 2012
    2,348
    1,029
    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.
     
    atferrari likes this.
  9. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,571
    2,382
    I agree, I did warn it was not good practice.
    Max.
     
    JohnInTX likes this.
  10. JohnInTX

    Moderator

    Jun 26, 2012
    2,348
    1,029
    You did actually, Max. I missed that.
     
Loading...