I'm working on a small home project and hit a problem, using a pic 16F627. Having trouble getting this program to do anything, basically a simple main routine to pulse an led every so often just to know its working and when an alarm condition exists RB0/INT pin then call and interrupt routine that turns a relay on/off for a timed duration after which a variable is incremented.
The program will not compile giving the following errors:
Any chance someone can have a look and point me out to where im going wrong please?
Here's the code:
IntON
'Test the relay and the LEDs
SET PortB.2 ON
SET PORTB.1 ON
wait 1 s
SET PORTB.1 OFF
WAit 1 s
SET PortB.2 OFF
SET PORTB.1 OFF
SET PORTB.3 ON
wait 1 s
SET PORTB.3 OFF
On Interrupt extint0 call ALARM
MainLoop:
if Alarmcount = 10 then GOTO FAILED
Wait 10 s
SET PORTB.2 ON
wait 1 s
SET PORTB.2 OFF
goto MainLoop
Sub Alarm
For i = 1 to 20
SET PORTB.1 ON
SET PORTB.2 ON
wait 1 s
SET PORTB1.OFF
SET PORTB.2 OFF
wait 1 s
next i
Alarmcount = Alarmcount + 1
End Sub
FAILED:
IntOff
SET PORTB.2 ON
WAIT 1 s
SET PORTB.2 OFF
SET PORTB.2 ON
wait 1 s
SET PORTB.3 OFF
wait 60 s
Alarmcount = 0
GOTO FAILED
The last bit is my attemt at disabling the alarm should it repeatly be triggered i.e. faulty sensor so turns interrupts off and enters a loop to just flash a fault led.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You'll need to look at the LST file to find out which instruction is on line 157. Maybe post up that file on here and the it can be cross referenced :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi guys
I'm working on a small home project and hit a problem, using a pic 16F627. Having trouble getting this program to do anything, basically a simple main routine to pulse an led every so often just to know its working and when an alarm condition exists RB0/INT pin then call and interrupt routine that turns a relay on/off for a timed duration after which a variable is incremented.
The program will not compile giving the following errors:
ASM: Compiled.asm 157: Error [108] illegal character (,)
ASM: Compiled.asm 157: Error [128] missing argument(s)
Any chance someone can have a look and point me out to where im going wrong please?
Here's the code:
IntON
'Test the relay and the LEDs
SET PortB.2 ON
SET PORTB.1 ON
wait 1 s
SET PORTB.1 OFF
WAit 1 s
SET PortB.2 OFF
SET PORTB.1 OFF
SET PORTB.3 ON
wait 1 s
SET PORTB.3 OFF
On Interrupt extint0 call ALARM
MainLoop:
if Alarmcount = 10 then GOTO FAILED
Wait 10 s
SET PORTB.2 ON
wait 1 s
SET PORTB.2 OFF
goto MainLoop
Sub Alarm
For i = 1 to 20
SET PORTB.1 ON
SET PORTB.2 ON
wait 1 s
SET PORTB1.OFF
SET PORTB.2 OFF
wait 1 s
next i
Alarmcount = Alarmcount + 1
End Sub
FAILED:
IntOff
SET PORTB.2 ON
WAIT 1 s
SET PORTB.2 OFF
SET PORTB.2 ON
wait 1 s
SET PORTB.3 OFF
wait 60 s
Alarmcount = 0
GOTO FAILED
The last bit is my attemt at disabling the alarm should it repeatly be triggered i.e. faulty sensor so turns interrupts off and enters a loop to just flash a fault led.
You'll need to look at the LST file to find out which instruction is on line 157. Maybe post up that file on here and the it can be cross referenced :)
Thanks for the replies guys, heres the list file (quite large):
gpasm-0.13.4 beta compiled.asm3-22-2009 19:00:01 PAGE 1
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00001 ;Program compiled by Great Cow BASIC (0.9 24/1/2009)
00002 ;Need help? See the GCBASIC forums at http://sourceforge.net/forum/?group_id=169286,
00003 ;check the documentation or email w_cholmondeley@users.sourceforge.net.
00004
00005 ;********************************************************************************
00006
00007 ;Set up the assembler options (Chip type, clock source, other bits and pieces)
00008 LIST p=16F627, r=DEC
00009 #include <P16F627.inc>
00001 LIST
00002 ; P16F627.INC Standard Header File, Version 1.01 Microchip Technology, Inc.
00261 LIST
002007 3F49 00010 __CONFIG _XT_OSC & _WDT_OFF & _LVP_OFF & _MCLRE_OFF
00011
00012 ;********************************************************************************
00013
00014 ;Set aside memory locations for variables
00000020 00015 ALARMCOUNT equ 32
00000021 00016 DELAYTEMP equ 33
00000022 00017 DELAYTEMP2 equ 34
00000023 00018 I equ 35
00000024 00019 PORTB1 equ 36
00000025 00020 RANDOMSEED equ 37
00000026 00021 RANDOMSEED_H equ 38
00000027 00022 SysIntOffCount equ 39
00000028 00023 SysSTATUS equ 40
00000029 00024 SysW equ 41
0000002A 00025 SysWaitTempMS equ 42
0000002B 00026 SysWaitTempMS_H equ 43
0000002C 00027 SysWaitTempS equ 44
00028
00029 ;********************************************************************************
00030
00031 ;Jump to initialisation code when PIC is reset
0000 00032 ORG 0
0000 207F 00033 call INITSYS
0001 2814 00034 goto SystemInitialise
00035
00036 ;********************************************************************************
00037
00038 ;Interrupt vector
0004 00039 ORG 4
00040 ;Save Context
0004 00A9 00041 movwf SysW
0005 0E03 00042 swapf STATUS,W
0006 00A8 00043 movwf SysSTATUS
0007 01A7 00044 clrf SysIntOffCount
0008 0AA7 00045 incf SysIntOffCount,F
00046 ;Call ON INTERRUPT handlers
0009 1C8B 00047 btfss INTCON,INTF
000A 280E 00048 goto NotINTF
000B 2058 00049 call ALARM
000C 108B 00050 bcf INTCON,INTF
000D 280E 00051 goto INTERRUPTDONE
gpasm-0.13.4 beta compiled.asm3-22-2009 19:00:01 PAGE 2
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
000E 00052 NotINTF
000E 00053 INTERRUPTDONE
00054 ;Restore Context
000E 01A7 00055 clrf SysIntOffCount
000F 0E28 00056 swapf SysSTATUS,W
0010 0083 00057 movwf STATUS
0011 0EA9 00058 swapf SysW,F
0012 0E29 00059 swapf SysW,W
0013 0009 00060 retfie
00061
00062 ;********************************************************************************
00063
00064 ;Various initialisation routines, automatically called by GCBASIC
0014 00065 SystemInitialise
00066
00067 ;********************************************************************************
00068
00069 ;Enable interrupts
0014 178B 00070 bsf INTCON,GIE
0015 170B 00071 bsf INTCON,PEIE
0016 01A7 00072 clrf SysIntOffCount
00073
00074 ;********************************************************************************
00075
00076 ;Start of the main program
0017 1683 1303 00077 banksel TRISA
0019 1485 00078 bsf TRISA,1
001A 1406 00079 bsf TRISB,0
001B 1086 00080 bcf TRISB,1
001C 1106 00081 bcf TRISB,2
001D 1186 00082 bcf TRISB,3
001E 1206 00083 bcf TRISB,4
001F 1286 00084 bcf TRISB,5
0020 1306 00085 bcf TRISB,6
0021 1386 00086 bcf TRISB,7
0022 1283 1303 00087 banksel SYSINTOFFCOUNT
0024 03A7 00088 decf SysIntOffCount,F
0025 1903 00089 btfsc STATUS,Z
0026 178B 00090 bsf INTCON,GIE
0027 1506 00091 bsf PORTB,2
0028 1486 00092 bsf PORTB,1
0029 3001 00093 movlw 1
002A 00AC 00094 movwf SysWaitTempS
002B 2077 00095 call Delay_S
002C 1086 00096 bcf PORTB,1
002D 3001 00097 movlw 1
002E 00AC 00098 movwf SysWaitTempS
002F 2077 00099 call Delay_S
0030 1106 00100 bcf PORTB,2
0031 1086 00101 bcf PORTB,1
0032 1586 00102 bsf PORTB,3
0033 3001 00103 movlw 1
0034 00AC 00104 movwf SysWaitTempS
0035 2077 00105 call Delay_S
gpasm-0.13.4 beta compiled.asm3-22-2009 19:00:01 PAGE 3
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0036 1186 00106 bcf PORTB,3
0037 160B 00107 bsf INTCON,INTE
0038 00108 MAINLOOP
0038 300A 00109 movlw 10
0039 0220 00110 subwf ALARMCOUNT,W
003A 1903 00111 btfsc STATUS, Z
003B 2845 00112 goto FAILED
003C 300A 00113 movlw 10
003D 00AC 00114 movwf SysWaitTempS
003E 2077 00115 call Delay_S
003F 1506 00116 bsf PORTB,2
0040 3001 00117 movlw 1
0041 00AC 00118 movwf SysWaitTempS
0042 2077 00119 call Delay_S
0043 1106 00120 bcf PORTB,2
0044 2838 00121 goto MAINLOOP
0045 00122 FAILED
0045 0AA7 00123 incf SysIntOffCount,F
0046 138B 00124 bcf INTCON,GIE
0047 1506 00125 bsf PORTB,2
0048 3001 00126 movlw 1
0049 00AC 00127 movwf SysWaitTempS
004A 2077 00128 call Delay_S
004B 1106 00129 bcf PORTB,2
004C 1506 00130 bsf PORTB,2
004D 3001 00131 movlw 1
004E 00AC 00132 movwf SysWaitTempS
004F 2077 00133 call Delay_S
0050 1186 00134 bcf PORTB,3
0051 303C 00135 movlw 60
0052 00AC 00136 movwf SysWaitTempS
0053 2077 00137 call Delay_S
0054 01A0 00138 clrf ALARMCOUNT
0055 2845 00139 goto FAILED
0056 00140 BASPROGRAMEND
0056 0063 00141 sleep
0057 2857 00142 goto $
00143
00144 ;********************************************************************************
00145 ;Subroutines included in program
00146 ;********************************************************************************
00147
0058 00148 ALARM
0058 01A3 00149 clrf I
0059 00150 SysForLoop1
0059 0AA3 00151 incf I,F
005A 1486 00152 bsf PORTB,1
005B 1506 00153 bsf PORTB,2
005C 3001 00154 movlw 1
005D 00AC 00155 movwf SysWaitTempS
005E 2077 00156 call Delay_S
Error [108] : Illegal Character (,)
Error [128] : Missing argument(s).
005F 00157 bsf PORTB1,
gpasm-0.13.4 beta compiled.asm3-22-2009 19:00:01 PAGE 4
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
005F 1106 00158 bcf PORTB,2
0060 3001 00159 movlw 1
0061 00AC 00160 movwf SysWaitTempS
0062 2077 00161 call Delay_S
0063 3014 00162 movlw 20
0064 0223 00163 subwf I,W
0065 1C03 00164 btfss STATUS, C
0066 2859 00165 goto SysForLoop1
0067 0AA0 00166 incf ALARMCOUNT,F
0068 0008 00167 return
00168
00169 ;********************************************************************************
00170
0069 00171 Delay_MS
0069 0AAB 00172 incf SysWaitTempMS_H, F
006A 00173 DMS_START
006A 300A 00174 movlw 10
006B 00A2 00175 movwf DELAYTEMP2
006C 00176 DMS_OUTER
006C 3021 00177 movlw 33
006D 00A1 00178 movwf DELAYTEMP
006E 00179 DMS_INNER
006E 0BA1 00180 decfsz DELAYTEMP, F
006F 286E 00181 goto DMS_INNER
0070 0BA2 00182 decfsz DELAYTEMP2, F
0071 286C 00183 goto DMS_OUTER
0072 0BAA 00184 decfsz SysWaitTempMS, F
0073 286A 00185 goto DMS_START
0074 0BAB 00186 decfsz SysWaitTempMS_H, F
0075 286A 00187 goto DMS_START
0076 0008 00188 return
00189
00190 ;********************************************************************************
00191
0077 00192 Delay_S
0077 00193 DS_START
0077 30E8 00194 movlw 232
0078 00AA 00195 movwf SysWaitTempMS
0079 3003 00196 movlw 3
007A 00AB 00197 movwf SysWaitTempMS_H
007B 2069 00198 call Delay_MS
007C 0BAC 00199 decfsz SysWaitTempS, F
007D 2877 00200 goto DS_START
007E 0008 00201 return
00202
00203 ;********************************************************************************
00204
007F 00205 INITSYS
007F 3007 00206 movlw 7
0080 009F 00207 movwf CMCON
0081 0185 00208 clrf PORTA
0082 0186 00209 clrf PORTB
0083 0008 00210 return
00211
gpasm-0.13.4 beta compiled.asm3-22-2009 19:00:01 PAGE 5
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00212 ;********************************************************************************
00213
gpasm-0.13.4 beta compiled.asm3-22-2009 19:00:01 PAGE 6
SYMBOL TABLE
LABEL VALUE
ADEN 00000003
ALARM 00000058
ALARMCOUNT 00000020
BASPROGRAMEND 00000056
BRGH 00000002
C 00000000
C1INV 00000004
C1OUT 00000006
C2INV 00000005
C2OUT 00000007
CCP1CON 00000017
CCP1IE 00000002
CCP1IF 00000002
CCP1M0 00000000
CCP1M1 00000001
CCP1M2 00000002
CCP1M3 00000003
CCP1X 00000005
CCP1Y 00000004
CCPR1H 00000016
CCPR1L 00000015
CIS 00000003
CM0 00000000
CM1 00000001
CM2 00000002
CMCON 0000001F
CMIE 00000006
CMIF 00000006
CREN 00000004
CSRC 00000007
DC 00000001
DELAYTEMP 00000021
DELAYTEMP2 00000022
DMS_INNER 0000006E
DMS_OUTER 0000006C
DMS_START 0000006A
DS_START 00000077
Delay_MS 00000069
Delay_S 00000077
EEADR 0000009B
EECON1 0000009C
EECON2 0000009D
EEDATA 0000009A
EEIE 00000007
EEIF 00000007
F 00000001
FAILED 00000045
FERR 00000002
FSR 00000004
GIE 00000007
I 00000023
INDF 00000000
INITSYS 0000007F
gpasm-0.13.4 beta compiled.asm3-22-2009 19:00:01 PAGE 7
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
INTCON 0000000B
INTE 00000004
INTEDG 00000006
INTERRUPTDONE 0000000E
INTF 00000001
IRP 00000007
MAINLOOP 00000038
NOT_BO 00000000
NOT_BOD 00000000
NOT_BOR 00000000
NOT_PD 00000003
NOT_POR 00000001
NOT_RBPU 00000007
NOT_T1SYNC 00000002
NOT_TO 00000004
NotINTF 0000000E
OERR 00000001
OPTION_REG 00000081
OSCF 00000003
PCL 00000002
PCLATH 0000000A
PCON 0000008E
PEIE 00000006
PIE1 0000008C
PIR1 0000000C
PORTA 00000005
PORTB 00000006
PORTB1 00000024
PR2 00000092
PS0 00000000
PS1 00000001
PS2 00000002
PSA 00000003
RANDOMSEED 00000025
RANDOMSEED_H 00000026
RBIE 00000003
RBIF 00000000
RCIE 00000005
RCIF 00000005
RCREG 0000001A
RCSTA 00000018
RD 00000000
RP0 00000005
RP1 00000006
RX9 00000006
RX9D 00000000
SPBRG 00000099
SPEN 00000007
SREN 00000005
STATUS 00000003
SYNC 00000004
SysForLoop1 00000059
SysIntOffCount 00000027
SysSTATUS 00000028
gpasm-0.13.4 beta compiled.asm3-22-2009 19:00:01 PAGE 8
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
SysW 00000029
SysWaitTempMS 0000002A
SysWaitTempMS_H 0000002B
SysWaitTempS 0000002C
SystemInitialise 00000014
T0CS 00000005
T0IE 00000005
T0IF 00000002
T0SE 00000004
T1CKPS0 00000004
T1CKPS1 00000005
T1CON 00000010
T1OSCEN 00000003
T2CKPS0 00000000
T2CKPS1 00000001
T2CON 00000012
TMR0 00000001
TMR1CS 00000001
TMR1H 0000000F
TMR1IE 00000000
TMR1IF 00000000
TMR1L 0000000E
TMR1ON 00000000
TMR2 00000011
TMR2IE 00000001
TMR2IF 00000001
TMR2ON 00000002
TOUTPS0 00000003
TOUTPS1 00000004
TOUTPS2 00000005
TOUTPS3 00000006
TRISA 00000085
TRISB 00000086
TRMT 00000001
TX9 00000006
TX9D 00000000
TXEN 00000005
TXIE 00000004
TXIF 00000004
TXREG 00000019
TXSTA 00000098
VR0 00000000
VR1 00000001
VR2 00000002
VR3 00000003
VRCON 0000009F
VREN 00000007
VROE 00000006
VRR 00000005
W 00000000
WR 00000001
WREN 00000002
WRERR 00000003
Z 00000002
gpasm-0.13.4 beta compiled.asm3-22-2009 19:00:01 PAGE 9
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
_BODEN_OFF 00003FBF_BODEN_ON 00003FFF_CP_50 00002BFF_CP_75 000017FF_CP_ALL 000003FF_CP_OFF 00003FFF_DATA_CP_OFF 00003FFF_DATA_CP_ON 00003EFF_ER_OSC_CLKOUT 00003FFF_ER_OSC_NOCLKOUT 00003FFE_EXTCLK_OSC 00003FEF_HS_OSC 00003FEE_INTRC_OSC_CLKOUT 00003FFD_INTRC_OSC_NOCLKOUT 00003FFC_LP_OSC 00003FEC_LVP_OFF 00003F7F_LVP_ON 00003FFF_MCLRE_OFF 00003FDF_MCLRE_ON 00003FFF_PWRTE_OFF 00003FFF_PWRTE_ON 00003FF7_WDT_OFF 00003FFB_WDT_ON _XT_OSC__16F627klzzwxh:10031klzzwxh:10032klzzwxh:10033klzzwxh:10034klzzwxh:10035klzzwxh:10036klzzwxh:10037klzzwxh:10038klzzwxh:10039klzzwxh:10040klzzwxh:10041klzzwxh:10042klzzwxh:10043klzzwxh:10044klzzwxh:10045klzzwxh:10046klzzwxh:10047klzzwxh:10048klzzwxh:10049klzzwxh:10050klzzwxh:10051klzzwxh:10052klzzwxh:10053klzzwxh:10054klzzwxh:10055 00000001
MEMORY USAGE MAP klzzwxh:10080'X' = Used,klzzwxh:10082 '-' = Unusedklzzwxh:10081
00000000 : XX--XXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXklzzwxh:1008300000040 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXklzzwxh:1008400000080 : XXXX------------ ---------------- ---------------- ----------------klzzwxh:1008500002000 : -------X-------- ---------------- ---------------- ----------------
All other memory blocks unused.
Program Memory Words Used: 131
Errorsklzzwxh:10086klzzwxh:10087 :klzzwxh:10088klzzwxh:10089klzzwxh:10090klzzwxh:10091klzzwxh:10092klzzwxh:10093 2klzzwxh:10118Warnings :klzzwxh:10094klzzwxh:10095klzzwxh:10096klzzwxh:10097klzzwxh:10098klzzwxh:10099 0 reported,klzzwxh:10100klzzwxh:10101klzzwxh:10102klzzwxh:10103klzzwxh:10104klzzwxh:10105 0 suppressedklzzwxh:10119Messages :klzzwxh:10106klzzwxh:10107klzzwxh:10108klzzwxh:10109klzzwxh:10110klzzwxh:10111 0 reported,klzzwxh:10112klzzwxh:10113klzzwxh:10114klzzwxh:10115klzzwxh:10116klzzwxh:10117 9 suppressed
Is just a sintax error, here:
For i = 1 to 20
SET PORTB.1 ON
SET PORTB.2 ON
wait 1 s
SET PORTB1.OFF '<<<<<<<<<< HERE
SET PORTB.2 OFF
wait 1 s
next i
Any ideas please as this is driving me absolutely nuts?
As someone else previously said it is a typo:
Sub Alarm
For i = 1 to 20
SET PORTB.1 ON
SET PORTB.2 ON
wait 1 s
SET PORTB1.OFF <<<should be >>> SET PORTB.1 OFF
SET PORTB.2 OFF
wait 1 s
next i
Alarmcount = Alarmcount + 1
End Sub