Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 02:26 27 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Interrupts

Author Message
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1873
Posted: 08:41pm 27 Jan 2013
Copy link to clipboard 
Print this post

I'm running a program that uses an interrupt. All is OK, the interrupt runs OK, but when it gets the IRETURN it must return into the middle of A 'Do-Loop' and I get an error message 'Loop without matching Do'.
Am I doing something wrong.
Paul.

"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 09:28pm 27 Jan 2013
Copy link to clipboard 
Print this post

Sounds like a bug to me. Can you demonstrate the fault with a short program (ie, less than 10 lines)?
Geoff Graham - http://geoffg.net
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1873
Posted: 10:20pm 27 Jan 2013
Copy link to clipboard 
Print this post

Geoff,
I wrote a snipped of code and it worked ok.
What I am doing is jumping out of your GPS routine with an interrupt. If it happens to return in the first part it works ok but if it returns during the GOSUB I get the LOOP without DO.
Paul
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1873
Posted: 12:09am 28 Jan 2013
Copy link to clipboard 
Print this post

Something I forgot to mention. I get the error on the line of the IRETURN I would have expected to get a LOOP without DO error on the line of the LOOP.
Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1873
Posted: 12:44pm 28 Jan 2013
Copy link to clipboard 
Print this post

Geoff,
The best I can do to demonstrate the problem was to modify your GPS routine to do the same as I am doing in my program. I have put in an interrupt to jump to a time display for a few seconds before it goes back to displaying the position.
The error occurs in line 282 'Do Without Matching Loop'
My modified code...



10 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''
20 ' Demonstration of parsing the NMEA string produced by a GPS module
30 ' Geoff Graham - Sept 2011
40 '
50 ' All GPS modules are guaranteed to produce the GPRMC string60 ' See http://
70 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''
80 SetPin 1,6,930
100 max = 20 ' maximum nbr of params
110 Dim arg$(max) ' used to hold the data fields
120 '
130 Open "COM1:4800" As #1
140 '
150 Do ' loop forever
160 GoSub 800 ' get the next line
170 If arg$(0) = "GPRMC" Then ' GPRMC contains lat/long
180 If arg$(2) = "A" Then ' "A" means locked on to satellite
185 If flag=1 Then GoTo 280 'JUMP TO TIME DISPLAY
190 Print "Latitude = "; Left$(arg$(3), 2); " "; Mid$(arg$(3), 3);
200 Print " "; arg$(4);
210 Print " Longitude = "; Left$(arg$(5), 3); " "; Mid$(arg$(5), 4);
220 Print " "; arg$(6)
230 Else
240 Print "GPS searching..."
250 EndIf
260 EndIf
270 Loop
280 Print "Time "arg$(1)
281 x=x+1 'DELAY
282 If x=10 Then flag=0:IReturn
283 GoTo 160
290 '
300 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''
310 ' subroutine to load the GPS data fields into the array arg$()
320 ' returns with the array populated
800 Do ' subroutine start
810 Do While Input$(1, #1) <> "$" : Loop ' wait for the start
820 For i = 0 To max
830 arg$(i) = "" ' clear ready for data
840 Do ' loops until a specific exit
850 x$ = Input$(1, #1) ' get the character
860 If x$ = "," Then Exit ' new data field, increment i
870 If x$ = "*" Then Return ' we have all the data so return
880 arg$(i) = arg$(i) + x$ ' add to the data
890 Loop ' loop back for the next charurn
900 Next i ' move to the next data field
910 Print "Corrupt data..." ' exceeded max data items
920 Loop
930 Flag=1:x=0 'INTERRUPT TO TIME DISPLAY
940 GoTo 160
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1425
Posted: 12:57pm 28 Jan 2013
Copy link to clipboard 
Print this post

That is a bit tough to follow.

I think you are jumping into the middle of a loop from outside the loop. Even without the interrupt code, there is a line (283) that jumps into a loop.Edited by CircuitGizmos 2013-01-29
Micromites and Maximites! - Beginning Maximite
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1873
Posted: 02:34pm 28 Jan 2013
Copy link to clipboard 
Print this post

Yeh, how stupid not to see that I should be jumping back to 150 not 160.
Sorry all.

Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
greybeard
Senior Member

Joined: 04/01/2010
Location: Australia
Posts: 161
Posted: 03:07pm 28 Jan 2013
Copy link to clipboard 
Print this post

I'd strongly suggest that you lose the line numbers and use labels only where needed for targets. Also consider indentation. The reasoning behind doing so is to reduce the 'clutter' and make your code a little more readable.
Something else to consider is write and comment code on the assumption that in 10 years time you will have to debug it. ie simple, structured and formatted code leaves the brain cells to concentrate on the content and intention of the code. Not get bogged down just trying to follow it.
If you are struggling with code size then all bets are off but otherwise, the memory and storage are already paid for, you may as well us them

Edited by greybeard 2013-01-30
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1873
Posted: 06:38pm 28 Jan 2013
Copy link to clipboard 
Print this post

Thanks for the suggestions, but that code was only meant to be a demo of the problem.
Gizmo, that was not my problem after all if you look at Geoffs code he does the same thing line 870 jumps back to line 160.
The problem was with the Ireturn so I fixed the problem by Interrupting to a routine which simply sets a flag and Ireturns immediately. The program then does what I want for a time before the flag is reset to zero and the main program resumes.
All is now working fine.
Thanks to all who helped.

Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024