Then you've been lucky so far, because NO, PicBasic does NOT take care of such scenarios. That's why there's ON INTERRUPT, which allows basic language statements in an interrupt routine. Unfortunately, it also imposes severe limitations on how the interrupts are handled.
With ASM interrupts, you can get away with basic variable assignments like detTone = 0, or simple addition and subtraction timer1_ofcnt = timer1_ofcnt +1. But anything more complex like ... if timer0 > 240 then timer0 = 1, will need to use PBP's system variables which is a BIG No-No. Essentially, any command that places it's code in the "Library" will have this problem. Most definitely SEROUT will not work, and using those serouts in the ISR for debugging will cause new problems of their own, so you won't be seeing the problems you are trying to debug. And then in the getdtmf routine you've got a FOR loop, an ARRAY operation, and a lot of stuff that's commented out with multiple math terms and shifts and and ...<hr>
PBP sets aside several RAM locations with the variables R0 thru R8, some RR? RM? and T? variables. Most of them are listed in the PBPPIC14.RAM file in your PBP folder.
When a command starts, it copies any parameters to the system variables and calls the library routine to actually accomplish the task. As that command continues to run, those variables will be used to count loops, keeps track of time or different states as needed.
If an interrupt happens, it stops that command in the middle and jumps to the ISR. If in the ISR you now run a basic language statement that uses the library, it will copy it's parameters to the system variables in preparation to run the library routine, which overwrites everything that the command that was interrupted was using. The interrupt itself will work fine. But once it returns from the interrupt, the command that was previously running has no idea where it left off. And since the system variables now have data that was not even meant for that type of command, many different errors are possible, wrong answers, lock-ups, resets, invalid branches.
With DT_INTS that I pointed to previously, it saves the state of PBP's system variables, runs the ISR, then restores the system variables before returning from the ISR. This allows basic language statements to be used in ASM interrupts without corrupting PBP's normal flow.
<br>
Bookmarks