trailrider
New Member
Hi
I'm really really new to PIC programming and am trying to get a motor control program running but MPLAB IDE v6.61 doesn't want to compile the code (copied below)
list p=16F84A ; list directive to define processor
#include <p16F84.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_ON & _PWRTE_ON & _RC_OSC
; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
;***** VARIABLE DEFINITIONS (examples)
; example of using Uninitialized Data Section
INT_VAR UDATA 0x0C
w_temp RES 1 ; variable used for context saving
status_temp RES 1 ; variable used for context saving
; example of using Overlayed Uninitialized Data Section
; in this example both variables are assigned the same GPR location by linker
G_DATA UDATA_OVR ; explicit address can be specified
flag RES 2 ; temporary variable (shared locations - G_DATA)
G_DATA UDATA_OVR
count RES 2 ; temporary variable (shared locations - G_DATA)
HF equ 00001000
LF equ 00000100
FLAG_LO equ 00000010
FLAG_HI equ 00000100
;**********************************************************************
RESET_VECTOR CODE 0x000 ; processor reset vector
goto start ; go to beginning of program
MAIN CODE
start;set PORTA to input
CLRF PORTA ; Initialize PORTA by
; setting output
; data latches
BSF STATUS, RP0 ; Select Bank 1
MOVLW 0x0F ; Value used to
; initialize data
; direction
MOVWF TRISA ; Set RA<3:0> as inputs
; RA4 as outputs
; TRISA<7:5> are always
; read as ’0’.
;set PORTB to output
CLRF PORTB ; Initialize PORTB by
; setting output
; data latches
BSF STATUS, RP0 ; Select Bank 1
MOVLW 0x8F ; Value used to
; initialize data
; direction
MOVWF TRISB ; Set RB<3:0> as inputs
; RB<6:4> as outputs
; RB7 as input
movf PORTA,w ;Get input
subwf HF,w ;HF is RA3 high -> upshift
btfss STATUS,Z ;if hf-output=equality, shift up
goto ChkDwn ; else shift down
subwf LF,w
btfss STATUS,Z
goto ChkUp
ChkUp:
movf PORTB,w
subwf FLAG_HI,w
btfss STATUS,Z
return
goto Up
Up:
movlw 00100000
movwf PORTB
goto Wait movlw 00000000
movwf PORTB
end
ChkDwn:
movf PORTB,w
subwf FLAG_LO,w
btfss STATUS,Z
return
goto Down
Down:
movlw 00010000
movwf PORTB
goto Wait
movlw 00000000
movwf PORTB
end
The stuff in blue was part of the template (ie i didn't write it). Wait is a little counter routine to ensure the outputs stay high for long enough.
The problem is as follows. When I go to Project>Quickbuild, I get the following error message (among others, but the rest are more to do with the fact that I'm not building it as a project):
Error[113] C:\DOCUMENTS AND SETTINGS\ZAC\MY DOCUMENTS\UNI\2004\SEM 1\EEB889\EEB889_DERAILLEUR.ASM 115 : Symbol not previously defined (ChkDwn)
the line it refers to is in green.
I also get a similar message for the wait routine which refers to the red line:
Error[113] C:\DOCUMENTS AND SETTINGS\ZAC\MY DOCUMENTS\UNI\2004\SEM 1\EEB889\EEB889_DERAILLEUR.ASM 130 : Symbol not previously defined (Wait)
Does anyone have any idea as to what is going on here?
I added the colons in after looking through a few textbooks but nothing changes.
Any help would be much appreciated.
I'm really really new to PIC programming and am trying to get a motor control program running but MPLAB IDE v6.61 doesn't want to compile the code (copied below)
list p=16F84A ; list directive to define processor
#include <p16F84.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_ON & _PWRTE_ON & _RC_OSC
; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
;***** VARIABLE DEFINITIONS (examples)
; example of using Uninitialized Data Section
INT_VAR UDATA 0x0C
w_temp RES 1 ; variable used for context saving
status_temp RES 1 ; variable used for context saving
; example of using Overlayed Uninitialized Data Section
; in this example both variables are assigned the same GPR location by linker
G_DATA UDATA_OVR ; explicit address can be specified
flag RES 2 ; temporary variable (shared locations - G_DATA)
G_DATA UDATA_OVR
count RES 2 ; temporary variable (shared locations - G_DATA)
HF equ 00001000
LF equ 00000100
FLAG_LO equ 00000010
FLAG_HI equ 00000100
;**********************************************************************
RESET_VECTOR CODE 0x000 ; processor reset vector
goto start ; go to beginning of program
MAIN CODE
start;set PORTA to input
CLRF PORTA ; Initialize PORTA by
; setting output
; data latches
BSF STATUS, RP0 ; Select Bank 1
MOVLW 0x0F ; Value used to
; initialize data
; direction
MOVWF TRISA ; Set RA<3:0> as inputs
; RA4 as outputs
; TRISA<7:5> are always
; read as ’0’.
;set PORTB to output
CLRF PORTB ; Initialize PORTB by
; setting output
; data latches
BSF STATUS, RP0 ; Select Bank 1
MOVLW 0x8F ; Value used to
; initialize data
; direction
MOVWF TRISB ; Set RB<3:0> as inputs
; RB<6:4> as outputs
; RB7 as input
movf PORTA,w ;Get input
subwf HF,w ;HF is RA3 high -> upshift
btfss STATUS,Z ;if hf-output=equality, shift up
goto ChkDwn ; else shift down
subwf LF,w
btfss STATUS,Z
goto ChkUp
ChkUp:
movf PORTB,w
subwf FLAG_HI,w
btfss STATUS,Z
return
goto Up
Up:
movlw 00100000
movwf PORTB
goto Wait movlw 00000000
movwf PORTB
end
ChkDwn:
movf PORTB,w
subwf FLAG_LO,w
btfss STATUS,Z
return
goto Down
Down:
movlw 00010000
movwf PORTB
goto Wait
movlw 00000000
movwf PORTB
end
The stuff in blue was part of the template (ie i didn't write it). Wait is a little counter routine to ensure the outputs stay high for long enough.
The problem is as follows. When I go to Project>Quickbuild, I get the following error message (among others, but the rest are more to do with the fact that I'm not building it as a project):
Error[113] C:\DOCUMENTS AND SETTINGS\ZAC\MY DOCUMENTS\UNI\2004\SEM 1\EEB889\EEB889_DERAILLEUR.ASM 115 : Symbol not previously defined (ChkDwn)
the line it refers to is in green.
I also get a similar message for the wait routine which refers to the red line:
Error[113] C:\DOCUMENTS AND SETTINGS\ZAC\MY DOCUMENTS\UNI\2004\SEM 1\EEB889\EEB889_DERAILLEUR.ASM 130 : Symbol not previously defined (Wait)
Does anyone have any idea as to what is going on here?
I added the colons in after looking through a few textbooks but nothing changes.
Any help would be much appreciated.