Hello,
I am having a problem with my Picaxe 40X1 crashing. It crashes approximately every 5-15 minutes and resets to the beginning of the program (variable values are not retained, so it doesn't "goto 0").
Hardware includes...
The program has an interrupt which is called approximately every 0.125 of a second. The interrupt serves to keep the transducer inputs up to date so that they can be interrogated at any point in the program.
Interrestingly, in order to debug it, I commented out most of the interrupt (except for the user variable poking/peeking; interrupt timer reset) and the program doesn't crash.
More interestingly, I also commented out the whole program and put in some new code, just enough so I could see whether the interrupt was causing the crash - no crashes.
Therefore, I know that there is something in the interraction between the main program and the interrupt, which causes the crash.
Moreover I added sertxd commands to the beginning and end of each subroutine, and a breakpoint at the beginning of the program, so I now know the last place it goes before it crashes. This is consistent - I have checked it a number of times.
As the interrupt is called around 8 times per second and it can take up to 15 mins for the crash to occur, I suspect that the crash only occurs when the interrupt falls at an inopportune time within the loop. This is speculation, though, and I know that the crash does not always happen at exactly the same time with respect to the interrupt.
I shall post the code below. The program is a full 4kB so I will only post the parts I know to be problematic. I hope this gives someone enough info to tell me what's wrong. I am happy to post the full code on request.
So here we go.
Symbol declaration...
continues in next post...
I am having a problem with my Picaxe 40X1 crashing. It crashes approximately every 5-15 minutes and resets to the beginning of the program (variable values are not retained, so it doesn't "goto 0").
Hardware includes...
- an axe033 LCD display, with DS1307 clock on the i2c bus
- pwm contolled 12v motor via darlington transistor
- 3 off, smartec digital temperature probes
- analogue pressure transducer
- various valves controlled by solid state relays
The program has an interrupt which is called approximately every 0.125 of a second. The interrupt serves to keep the transducer inputs up to date so that they can be interrogated at any point in the program.
Interrestingly, in order to debug it, I commented out most of the interrupt (except for the user variable poking/peeking; interrupt timer reset) and the program doesn't crash.
More interestingly, I also commented out the whole program and put in some new code, just enough so I could see whether the interrupt was causing the crash - no crashes.
Therefore, I know that there is something in the interraction between the main program and the interrupt, which causes the crash.
Moreover I added sertxd commands to the beginning and end of each subroutine, and a breakpoint at the beginning of the program, so I now know the last place it goes before it crashes. This is consistent - I have checked it a number of times.
As the interrupt is called around 8 times per second and it can take up to 15 mins for the crash to occur, I suspect that the crash only occurs when the interrupt falls at an inopportune time within the loop. This is speculation, though, and I know that the crash does not always happen at exactly the same time with respect to the interrupt.
I shall post the code below. The program is a full 4kB so I will only post the parts I know to be problematic. I hope this gives someone enough info to tell me what's wrong. I am happy to post the full code on request.
So here we go.
Symbol declaration...
Code:
symbol dispcode=b6 'this byte tells lcd what to display at its next refresh -- see lcddisplay subroutine.
symbol cwt=b7 'cwt in degrees C
symbol hwt=b8 'hwt in degrees C
symbol mwt=b9 'mwt in tenths of degrees C above 30°C. Therefore 000=30°C; 255=55.5°C
symbol mpress=w5 'mw pressure. 10 bit adc. 0 = 0bar, 1024 ~= 10bar
symbol ticker=b12 'used to handle timing events
symbol tickerflag=b13 'check whether clock has 'ticked'
symbol muloc=87 'menu location
symbol varcode=86 'value of the system variable currently being changed
symbol varcode_old = 85
symbol muloc_old=88 'previous menu location
symbol dcpr_bot=90
symbol dcpr_top=91
symbol dcprevtop=230
symbol dcprevbot=231
symbol btnspace1=232
symbol btnspace2=233
symbol btnspace3=234
symbol ptdoneflag=106
symbol storeb4pt =107
symbol storeb5pt =108
symbol mpstore = 210
symbol mphighestword = 212
symbol mpnexthighestword = 214
symbol mplowestword = 216
symbol mpnextlowestword = 218
symbol mpinitial = 220
symbol settmp = 110 'equivalent to 41 degC - ie. temp*10-300
symbol mwtprevious = 89
continues in next post...
Last edited: