In SX Microcontrollers, SX/B Compiler and SX-Key Tool, RS_Jim wrote: In trying to chase down my problem with WKPND_B, I made some slight changes to the interupt program. 1 to set a bit in the timer routine every 1/100 of a second to use as a run bit for the tac and the second to the motor drive progarm to set the individual port bit instead of sending a whold byte to the port. The first time I run the new version the program immediately goes to sleep. When I run it under sxsim, I get a RETURNIW without an interupt error. In backsteping the program, I get to a step where it is supposed to be doing a jmp to A13. Instead it jmps to 13 which is in the middle of the ISR. Here is the listing of the Subroutine: [3] 1151 =000001EB TAC_RESULT: ;FUNC TAC_RESULT[/3] [3] 1152 [/3] [3] 1153 [/3] [3] 1154 ; 'this measurement.[/3] [3] 1155 01EB 0068 CLR __WPARAM12_LSB ; __wparam12 =0 [/3] [3] 1156 01EC 0069 CLR __WPARAM12_MSB [/3] [3] 1157 [/3] [3] 1158 01ED 072E SB Tdone ;\ SB Tdone[/3] [3] 1159 [/3] [3] 1160 01EE 0A13 jmp txit ;\ jmp txit THIS JMP instruction is where it jmps to ISR[/3] [3] 1161 [/3] [3] 1162 01EF 056E SETB TInhib ;\ SETB TInhib 'prevent interupt during[/3] [3] 1163 [/3] [3] 1164 01F0 001A BANK timing ; Bank @timing[/3] [3] 1165 [/3] [3] 1166 01F1 021C MOV __WPARAM34_LSB,Tac2_LSB ; __wparam34 = Tac2[/3] [3] 01F2 002A[/3] [3] 1167 01F3 021D MOV __WPARAM34_MSB,Tac2_MSB [/3] [3] 01F4 002B[/3] [3] 1168 [/3] [3] 1169 01F5 0216 MOV __WPARAM12_LSB,TacTime_LSB ; __wparam12 = TacTime[/3] [3] 01F6 0028[/3] [3] 1170 01F7 0217 MOV __WPARAM12_MSB,TacTime_MSB[/3] [3] 01F8 0029[/3] [3] 1171 [/3] [3] 1172 01F9 0217 CJB Tac2_MSB,TacTime_MSB,@__ELSE_2 ; if Tac2 > TacTime Then[/3] [3] 01FA 009D 0703 0011 0A0D[/3] [3] 1173 01FE 0743 JNZ @$+8 [/3] [3] 01FF 0011 0A06[/3] [3] 1174 0201 021C CJBE Tac2_LSB,TacTime_LSB,@__ELSE_2[/3] [3] 0202 0096 0603 0011 0A0D[/3] [3] 1175 [/3] [3] 1176 0206 0C00 ADD __WPARAM12_LSB,#$6000 & 255 ; __wparam12 = __wparam12 + $6000[/3] [3] 0207 01E8[/3] [3] 1177 0208 0C00 MOV W,#$6000 << 8 [/3] [3]****** C:\Documents and Settings\Jim the boss\My Documents\sx documents\Atactest1.SRC(1177) Line 1177, Warning 37, Pass 2: Literal truncated to 8 bits[/3] [3] 1178 0209 0603 SNC [/3] [3] 1179 020A 0C01 MOV W,#($6000 << 8)+1 [/3] [3]****** C:\Documents and Settings\Jim the boss\My Documents\sx documents\Atactest1.SRC(1179) Line 1179, Warning 37, Pass 2: Literal truncated to 8 bits[/3] [3] 1180 020B 0743 SZ [/3] [3] 1181 020C 01E9 ADD __WPARAM12_MSB,W [/3] [3] 1182 [/3] [3] 1183 =0000020D __ELSE_2: ; Endif[/3] [3] 1184 =0000020D __ENDIF_2: [/3] [3] 1185 [/3] [3] 1186 020D 046E clrb TInhib ; \clrb TInhib[/3] [3] 1187 [/3] [3] 1188 [/3] [3] 1189 ;' __wparam12 = tacTime - Tac2[/3] [3] 1190 020E 0C04 MOV __PARAMCNT,#4 ; __wparam12 = BCD_WORD_SUB __wparam12,__wparam34[/3] [3] 020F 002C[/3] [3] 1191 0210 0010 CALL @__BCD_WORD_SUB [/3] [3] 0211 09A4[/3] [3] 1192 [/3] [3] 1193 ;' Tac0 = Tac1 'handled in isr[/3] [3] 1194 ;' Tac1 = Tac2[/3] [3] 1195 ;' Tac2 = TacTime[/3] [3] 1196 0212 042E clrb TDone ; \clrb TDone 'wait for new info[/3] [3] 1197 [/3] [3] 1198 [/3] [3] 1199 =00000213 Txit: ;Txit:[/3] [3] 1200 [/3] [3] 1201 [/3] [3] 1202 ;'Txit1:[/3] [3] 1203 0213 0018 BANK 0 ;Bank 0[/3] [3] 1204 [/3] [3] 1205 [/3] [3] 1206 0214 0208 MOV tmpW1_LSB,__WPARAM12_LSB ; tmpW1 = __wparam12[/3] [3] 0215 0030[/3] [3] 1207 0216 0209 MOV tmpW1_MSB,__WPARAM12_MSB [/3] [3] 0217 0031[/3] [3] 1208 [/3] [3] 1209 0218 0210 MOV __PARAM1,tmpW1_LSB ;RETURN tmpW1[/3] [3] 0219 0028[/3] [3] 1210 021A 0211 MOV __PARAM2,tmpW1_MSB [/3] [3] 021B 0029[/3] 1211 021C 000D RETP I will get rid of the warning by changing the instruction from add $6000 to __wparam12 to ad $60 to __param2. Obviously I don't want the program to jmp into the 13th line of the ISR, only to move forward a fiew line to the end of the FUNC here is the SXB code for the TAC ' ------------------------------------------------------------------------- 'Tac_Result function that returns a word that contains the lapse 'time from the last revolution of the wheel ' ------------------------------------------------------------------------- FUNC TAC_RESULT __wparam12 =0 \ SB Tdone \ jmp txit \ SETB TInhib 'prevent interupt during this measurement. Bank @timing __wparam34 = Tac2 __wparam12 = TacTime if Tac2 > TacTime Then __wparam12 = __wparam12 + $6000 'seconds have rolled over Endif \clrb TInhib __wparam12 = BCD_WORD_SUB __wparam12,__wparam34 ' Tac0 = Tac1 'handled in isr ' Tac1 = Tac2 ' Tac2 = TacTime \clrb TDone 'wait for new info Txit: 'Txit1: Bank 0 tmpW1 = __wparam12 RETURN tmpW1 ENDFUNC Any Ideas why the unsual jmp is happening? ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=367719 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)