1st off wish to thank Darrel for a very useful routine. Now my issue. It seems when in a WHILE loop or a REPEAT..UNTIL look the interrupts are no longer detected. I am using the UART interrupts and they work flawlessly until I call a subroutine which has the WHILE loop and can't get out of it. I have a command protocol where I send a START command via serial which will call the looping program. I stop the loop by sending a STOP command. I minimized the routine to have only the loop and not the code within the loop to simply the trouble shooting. Below the code snippets.
The uart interrupt entry routine reduced to just the command of interest.
SERIALINT:
HSERIN [COMMAND,DEC1 MODE,DEC5 IODATA]
SELECT CASE COMMAND
CASE "N" 'Control scan position and start/stop PIEZO1
MOTORADDR = PIEZO1
SELECT CASE MODE
CASE STARTPOS 'READ START POS DATA 16-BITS
PIEZO1START = IODATA
CASE ENDPOS 'READ END POS DATA 16-BITS
PIEZO1END = IODATA
CASE STARTSCAN 'START SCANNING
SCAN = TRUE
HSEROUT ["START",13,10] '0-65535
CASE STOPSCAN 'STOP SCANNING
SCAN = FALSE
HSEROUT ["STOP",13,10] '0-65535
END SELECT
GOSUB BEGINSCAN
END SELECT
@ INT_RETURN
The subroutine being called below. When I send the start command it enters the routine fine but sending another command to stop it never enters the interrupt handler.
debugging lines to transmit START or STOP in the handler. START is sent to the terminal but STOP doesn't which shows it doesn't recognize another interrupt. Without the WHILE
loop, works fine. I commented the main code to make it as simple as possible
BEGINSCAN: 'START SCANNING PIEZO1
IF (PIEZO1END - PIEZO1START) < 1000 THEN
SCANSTEP = 1
ELSE
SCANSTEP = (PIEZO1END - PIEZO1START)/1000 'LIMIT TO 1000 STEPS
ENDIF
'
WHILE SCAN = TRUE
' SCANINDEX = PIEZO1START
' ARRAYCOUNT = 0
' WHILE SCANINDEX <= PIEZO1END
' PIEZO1POS = SCANINDEX
' GOSUB SETPIEZO
' PDSELECT = pd1 'CONVERT PD1 DATA AND STORE IN ARRAY
' GOSUB READPD
' PD1ARRAY[ARRAYCOUNT] = PD1DATA
' SCANINDEX = SCANINDEX + SCANSTEP
' ARRAYCOUNT = ARRAYCOUNT + 1
' WEND
'GOSUB SENDARRAY 'SEND SAVED DATA TO PC
WEND
RETURN
Is there something about WHILE or REPEATS that doesn't allow interrupts? I also put a 1 ms pause in the loop and same problem.
Bookmarks