Hi,
I want to start my home project to control ventilation fan by time period ON and time period OFF and to use LCD out for interface.
I have just started to write a code in Micro Code studio Plus v.3.0.0.5 with compiler PICBasic PRO v2.50C.
I made a starting (main) interrupt code as a basis for rest algorithm later. It is based on some desired info I have looked on the internet pages. Seems to be workable and started to compile this code. When compiling I have got some results like assembler errors as following:
Error xxx.asm 125[225] undefined symbol 'halfsec'
Error xxx.asm 126[225] undefined symbol 'halfsec'
Error xxx.asm 128[225] undefined symbol 'halfsec'
Error xxx.asm 129[225] undefined symbol 'unsec'
Error xxx.asm 137[225] undefined symbol 'interr'
As for me I can not understand those results at this stage and have no idea what was wrongin my code. Would you be so kind to look at my sourse code and help me to fix this problem in order to continue my project. Thank you inadvance and any ideas are appresiated.
Here is the code example for my project:
@ DEVICE pic16F628A, XT_OSC
@ DEVICE pic16F628A, WDT_ON
@ DEVICE pic16F628A, PWRT_ON
@ DEVICE pic16F628A, MCLR_OFF
@ DEVICE pic16F628A, BOD_ON
@ DEVICE pic16F628A, LVP_OFF
@ DEVICE pic16F628A, CPD_OFF
@ DEVICE pic16F628A, PROTECT_OFF
DEFINE OSC 4
define INTHAND Myint ' Define interrupt handler
counter var word 'to operate with unsec variable in main program
wsave var byte $20 system
ssave var byte bank0 system
psave var byte bank0 system
halfsec var byte
unsec var word
interr var byte
halfsec = 0 'clear the time variables
unsec = 0
interr = 0
INTCON = %11000000 'enable GIE and PEIE
T1CON = %00110101 'Configure TMR1 with clock/4 and prescaler 1/8
PIE1.0 = 1 'enable interrupt TMR1 overflow
goto Main ' Skip around interrupt handler
ASM ; Assembly language interrupt handler
; Save W, STATUS and PCLATH registers
Myint MOVWF wsave
SWAPF STATUS,W
CLRF STATUS
MOVWF ssave
MOVF PCLATH,W
MOVWF psave
; Interrupt code
MOVLW 221
MOVWF TMR1L
MOVLW 11
MOVWF TMR1H
BCF PIR1,0
INC halfsec
BTFSS halfsec,1
GOTO xxx
CLRF halfsec
INC unsec
; Restore PCLATH, STATUS and W registers
xxx MOVF psave,W
MOVWF PCLATH
SWAPF ssave,W
MOVWF STATUS
SWAPF wsave,F
SWAPF wsave,W
BSF interr,0 ;just a flag...
RETFIE
ENDASM
Main: 'Start of the main program
counter = unsec ' Or do something else...
goto Main ' Return to the main program
end ' End
Bookmarks