Pic12f509

Discussion in 'Programmer's Corner' started by tresguey, Aug 12, 2013.

  1. tresguey

    Thread Starter Member

    Apr 22, 2013
    55
    1
    I am unable to build this in MPLAB X. I cannot figure out what is wrong with it.

    Code ( (Unknown Language)):
    1.  
    2.  
    3.     list        p=12F509      
    4.     #include    <p12F509.inc>
    5.  
    6.     EXTERN      delay10_R       ; W x 10 ms delay
    7.    
    8.  
    9. ;***** CONFIGURATION
    10.                 ; ext reset, no code protect, no watchdog, int RC clock
    11.     __CONFIG    _MCLRE_ON & _CP_OFF & _WDT_OFF & _IntRC_OSC
    12.  
    13.  
    14. ;***** VARIABLE DEFINITIONS
    15.         UDATA_SHR
    16. sGPIO   res     1               ; shadow copy of GPIO
    17.  
    18.  
    19. ;***** RC CALIBRATION
    20. RCCAL   CODE    0x3FF           ; processor reset vector
    21.         res 1                   ; holds internal RC cal value, as a movlw k
    22.        
    23.  
    24. ;***** RESET VECTOR *****************************************************
    25. RESET   CODE    0x000           ; effective reset vector
    26.         movwf   OSCCAL          ; apply internal RC factory calibration
    27.         pagesel start
    28.         goto    start           ; jump to main code
    29.  
    30. ;***** Subroutine vectors
    31. delay10                         ; delay W x 10 ms
    32.         pagesel delay10_R
    33.         goto    delay10_R      
    34.  
    35.  
    36. ;***** MAIN PROGRAM *****************************************************
    37. MAIN    CODE
    38.  
    39. ;***** Initialisation
    40. start        
    41.         movlw   b'111101'       ; configure GP1 (only) as an output
    42.         tris    GPIO
    43.  
    44.         clrf    sGPIO           ; start with shadow GPIO zeroed
    45.  
    46. ;***** Main loop
    47. main_loop
    48.         ; toggle LED on GP1
    49.         movf    sGPIO,w         ; get shadow copy of GPIO
    50.         xorlw   b'000010'       ; toggle bit corresponding to GP1 (bit 1)
    51.         movwf   sGPIO           ;   in shadow register
    52.         movwf   GPIO            ; and write to GPIO
    53.         ; delay 0.5 s
    54.         movlw   .50             ; delay 50 x 10 ms = 500 ms
    55.         pagesel delay10         ;   -> 1 Hz flashing at 50% duty cycle
    56.         call    delay10        
    57.          
    58.         ; repeat forever  
    59.         pagesel main_loop    
    60.         goto    main_loop  
    61.  
    62.  
    63.         END
    64.  
     
  2. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    No hint as to what the error is? What does the compiler say?
     
  3. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,515
    2,369
    I get this message
    Error - could not find definition of symbol 'delay10_R' in file './test.o'.
    Also are you compiling in relative or absolute?
    Max.
     
  4. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Can you do a print screen of the error message window? If you double click on the error message it might take you to the line of code with the problem.
     
  5. tresguey

    Thread Starter Member

    Apr 22, 2013
    55
    1
    The code is from the Gooligum Baseline lesson three.

    Code ( (Unknown Language)):
    1.  
    2. make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
    3. make[1]: Entering directory `C:/Users/CP-122310/MPLABXProjects/Lesson 3.X'
    4. make  -f nbproject/Makefile-default.mk dist/default/production/Lesson_3.X.production.hex
    5. make[2]: Entering directory `C:/Users/CP-122310/MPLABXProjects/Lesson 3.X'
    6. "C:\Program Files (x86)\Microchip\MPLABX\mpasmx\mpasmx.exe" -q -p12f509 -l"build/default/production/_ext/1739558278/BA_L3-Flash_LED-main.lst" -e"build/default/production/_ext/1739558278/BA_L3-Flash_LED-main.err" -o"build/default/production/_ext/1739558278/BA_L3-Flash_LED-main.o" "../../Desktop/Baseline/3 - Modular code/BA_L3-Flash_LED-main.asm"
    7. "C:\Program Files (x86)\Microchip\MPLABX\mpasmx\mplink.exe"    -p12f509  -w  -m"dist/default/production/Lesson 3.X.production.map"   -z__MPLAB_BUILD=1  -odist/default/production/Lesson_3.X.production.cof  build/default/production/_ext/1739558278/BA_L3-Flash_LED-main.o    
    8. make[2]: *** [dist/default/production/Lesson_3.X.production.hex] Error 1
    9. make[1]: *** [.build-conf] Error 2
    10. make: *** [.build-impl] Error 2
    11. MPLINK 4.49, Linker
    12. Device Database Version 1.14
    13. Copyright (c) 1998-2011 Microchip Technology Inc.
    14. Error - could not find definition of symbol 'delay10_R' in file './build/default/production/_ext/1739558278/BA_L3-Flash_LED-main.o'.
    15. Errors    : 1
    16.  
    17. make[2]: Leaving directory `C:/Users/CP-122310/MPLABXProjects/Lesson 3.X'
    18. make[1]: Leaving directory `C:/Users/CP-122310/MPLABXProjects/Lesson 3.X'
    19.  
    20. BUILD FAILED (exit value 2, total time: 2s)
    21.  
     
  6. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,515
    2,369
    That is the same as I posted, it seems your external reference to delay10_R is missing or in error?
    Max.
     
  7. tresguey

    Thread Starter Member

    Apr 22, 2013
    55
    1
    Max...I have no idea what compiling in relative or absolute is. How can I find out how I am compiling?
     
  8. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,515
    2,369
    There is usually a question at the first build time, but you can change at any time from the Build Options/Project/MPASM
    Max.
     
  9. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,515
    2,369
    Did you do the lesson step by step and take note about including relocatable code?
    Such as the Delay10.asm included in the source files etc.
    Max.
     
  10. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    If you are intending to compile code to insert into a PIC then you want an absolute build.

    A relative build is for times you are creating a library function that needs to be relocatable to an arbitrary address (AFAIK).

    I believe MPLAB will bark at you if you try to program with a relative build and suggest the proper alternative.
     
  11. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,515
    2,369
    Have you edited the Delay10 file to include the GLOBAL directive?
    And do you have it in your source files, or alternatively the .o version in the Object file list?
    Max.
     
Loading...