Pic12f509

Thread Starter

tresguey

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

Rich (BB code):
    list        p=12F509      
    #include    <p12F509.inc>

    EXTERN      delay10_R       ; W x 10 ms delay
    

;***** CONFIGURATION
                ; ext reset, no code protect, no watchdog, int RC clock 
    __CONFIG    _MCLRE_ON & _CP_OFF & _WDT_OFF & _IntRC_OSC


;***** VARIABLE DEFINITIONS
        UDATA_SHR
sGPIO   res     1               ; shadow copy of GPIO


;***** RC CALIBRATION
RCCAL   CODE    0x3FF           ; processor reset vector
        res 1                   ; holds internal RC cal value, as a movlw k
        

;***** RESET VECTOR *****************************************************
RESET   CODE    0x000           ; effective reset vector
        movwf   OSCCAL          ; apply internal RC factory calibration 
        pagesel start
        goto    start           ; jump to main code

;***** Subroutine vectors
delay10                         ; delay W x 10 ms
        pagesel delay10_R
        goto    delay10_R       


;***** MAIN PROGRAM *****************************************************
MAIN    CODE

;***** Initialisation
start        
        movlw   b'111101'       ; configure GP1 (only) as an output
        tris    GPIO

        clrf    sGPIO           ; start with shadow GPIO zeroed

;***** Main loop
main_loop
        ; toggle LED on GP1
        movf    sGPIO,w         ; get shadow copy of GPIO
        xorlw   b'000010'       ; toggle bit corresponding to GP1 (bit 1)
        movwf   sGPIO           ;   in shadow register
        movwf   GPIO            ; and write to GPIO
        ; delay 0.5 s
        movlw   .50             ; delay 50 x 10 ms = 500 ms
        pagesel delay10         ;   -> 1 Hz flashing at 50% duty cycle
        call    delay10         
          
        ; repeat forever  
        pagesel main_loop     
        goto    main_loop   


        END
 

MaxHeadRoom

Joined Jul 18, 2013
28,684
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.
 

Markd77

Joined Sep 7, 2009
2,806
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.
 

Thread Starter

tresguey

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

Rich (BB code):
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `C:/Users/CP-122310/MPLABXProjects/Lesson 3.X'
make  -f nbproject/Makefile-default.mk dist/default/production/Lesson_3.X.production.hex
make[2]: Entering directory `C:/Users/CP-122310/MPLABXProjects/Lesson 3.X'
"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" 
"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     
make[2]: *** [dist/default/production/Lesson_3.X.production.hex] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
MPLINK 4.49, Linker
Device Database Version 1.14
Copyright (c) 1998-2011 Microchip Technology Inc.
Error - could not find definition of symbol 'delay10_R' in file './build/default/production/_ext/1739558278/BA_L3-Flash_LED-main.o'.
Errors    : 1

make[2]: Leaving directory `C:/Users/CP-122310/MPLABXProjects/Lesson 3.X'
make[1]: Leaving directory `C:/Users/CP-122310/MPLABXProjects/Lesson 3.X'

BUILD FAILED (exit value 2, total time: 2s)
 

MaxHeadRoom

Joined Jul 18, 2013
28,684
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.
 

ErnieM

Joined Apr 24, 2011
8,377
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.
 

MaxHeadRoom

Joined Jul 18, 2013
28,684
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.
 
Top