need your help again on interrupt problem

jyb

Senior Member
i use the interrupt system following the way you did describe but i fall on another problem wich is a stack overflow .using simulation i saw that each call to interrupt routine don't end correctly, never passing the return statment
this event produce if the last statment of the interrupt subroutine before return is setintflags %10000000,%10000000,(to re_enable interrupt service) executing this statment ,program jump directly to interrupt,calling itself and so the stack explode reaching to the 8° iteration
what i understand is: upon interrupt is enabled, immediately the subroutine loop on itself ,so i try to change timming, no work, nor changing the statments'place
i can't find, no more ideas to try

there is the subject of the mistery

interrupt:
gosub lectmatrice
timer = 65535
SetTimer 65224
SetIntFlags %10000000, %10000000
Return <<<<never pass by this return!!!

i know you know the solution
thanks by advance
jyb the frenchie
 

BeanieBots

Moderator
Does "gosub lectmatrice" ever return?

The interrupt is only re-enabled after the return is executed so even if the interrupt condition still exists, it should simply re-execute AFTER the return so I strongly believe the problem is in your subroutine.

Probably a good idea to post the entire code.
 

MartinM57

Moderator
For clarity, hoping BB doesn't mind...
Does "gosub lectmatrice" ever return?

The interrupt is only re-enabled after the return IN THE INTERRUPT ROUTINE (not any return that you just happen to meet in other routines called from the interrupt) is executed so even if the interrupt condition still exists, it should simply re-execute AFTER the return so I strongly believe the problem is in your subroutine.

Probably a good idea to post the entire code.
 

inglewoodpete

Senior Member
There was a version of the Programming Editor (PE version 5.2.4) that caused interrupts to go haywire when used to compile/download a programme. I know because I was caught by it.

Make sure you are using the latest PE.
 

jyb

Senior Member
symplified code cause same fault

hello all
i simplify my code to find what is wrong and it still bugging
if a owner of 40x2 could try this ,may be he obtain same fault
more strongest : if i remove from interrupt subroutine the two first lines(settimer off and setintflags off),what i get when running simulation is crash of programming editor and lone possibility to escape from this is "ctrl alt del" to access to program manager and kill the process!!

little code big troubles!!!




40x2 picaxe
pointeur2=0
'gosub initlcd' init lcd
'gosub start_clock'init clock
setfreq em40
timer = 65535
settimer 65000 ‘' settimer to count mode
setintflags %10000000,%10000000

main: inc pointeur2 if pointeur2=255 then let pointeur2=0 endif
goto main

lectmatrice:
sound 28, (100,5)
return


interrupt:
settimer off
setintflags off
gosub lectmatrice
timer = 65535
settimer 65000 ' settimer to count mode
setintflags %10000000,%10000000
return

running the code above ,the return from interrupt is never used and cause the stack pointer to crash on the 8° iteration (deep max )
 

jyb

Senior Member
found solution

this code runs correctly and one more time i confirm i am too bad in English
:confused:
thanks to all



setfreq em40
timer = 65535
settimer 65000

main: setintflags %10000000,%10000000 pause 10 goto main

lectmatrice:
sound 28, (100,5)
return



interrupt:
gosub lectmatrice
return
 

hippy

Ex-Staff (retired)
Whilst your code may run, it only enters the interrupt routine once. As the interrupts are not re-enabled you won't get further interrupts.

It appears that there may be an issue with simulating some programs using SETTIMER which we will investigate.

Programs running on a physical chip will not be affected by those simulator-only issues so, as long as the code is correct, the programs should work as expected.

The following code works on a physical 40X2 chip, generating an interrupt every 10ms when running at 8MHz, putting a 1Hz signal out on Output Pin C.0 ( leg 15 ) which can be observed with a LED+R connected between C.0 and 0V ...

#Picaxe 40X2
#No_Data
#No_Table

SetFreq M8

timer = 65535
SetTimer 65224
SetIntFlags %10000000, %10000000

Do : Loop

Interrupt:
w0 = w0 + 10
If w0 = 500 Then
Toggle c.0
w0 = 0
End If
timer = 65535
SetTimer 65224
SetIntFlags %10000000, %10000000
Return
 
Top