Two INTERRUPTS in Oshonsoft

Thread Starter

camerart

Joined Feb 25, 2013
3,724
Hi,
I always have trouble when programming INTERRUPTS. I'm using Oshonsoft BASIC.
I have examples using one INTERRUPT with TMR1 or TMR0, but now need two. HIGH and LOW

1/ When using two INTERRUPTS do I use two different TIMERS or if the times are changed, is one ok?

2/ Am I correct that once the INTERRUPT has triggered the whole of that INTERRUPT routine is carried out before resuming back to the main program LOOP?

or 3/ if there is a HIGH INTERRUPT will it break into the LOW INTERRUPT?

I'm reluctant to post my program, as I've been told it's difficult to read, and a bit spaghetti like :(

Camerart
 

ericgibbs

Joined Jan 29, 2010
18,766
hi C,
Note if you use Save System at the start of a LOW interrupt and a High interrupt occurs, with its Save System command [ which will take control of the program].
On returning to the LOW interrupt routine, the Saved System data may have been overwritten by the HIGH interrupt Save System.
So on RESUME you could get errors
OK.?
E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,724
hi C,
Note if you use Save System at the start of a LOW interrupt and a High interrupt occurs, with its Save System command [ which will take control of the program].
On returning to the LOW interrupt routine, the Saved System data may have been overwritten by the HIGH interrupt Save System.
So on RESUME you could get errors
OK.?
E
Hi E,
What does SYSTEM mean? Is it VARIABLES and calculations?
C
 

ericgibbs

Joined Jan 29, 2010
18,766
hi,
This is what Oshonsoft Basic creates for Save System
Saves data/regs to memory
E
; 81: Save System
MOVFF R0L,R0L_TEMP
MOVFF R0H,R0H_TEMP
MOVFF R3L,R3L_TEMP
MOVFF R3H,R3H_TEMP
MOVFF R4L,R4L_TEMP
MOVFF R4H,R4H_TEMP
MOVFF R8L,R8L_TEMP
MOVFF R8H,R8H_TEMP
MOVFF R9L,R9L_TEMP
MOVFF R9H,R9H_TEMP
MOVFF FSR0L,FSR0L_TEMP
MOVFF FSR0H,FSR0H_TEMP
MOVFF FSR1L,FSR1L_TEMP
MOVFF FSR1H,FSR1H_TEMP
 

Thread Starter

camerart

Joined Feb 25, 2013
3,724
hi,
This is what Oshonsoft Basic creates for Save System
Saves data/regs to memory
E
; 81: Save System
MOVFF R0L,R0L_TEMP
MOVFF R0H,R0H_TEMP
MOVFF R3L,R3L_TEMP
MOVFF R3H,R3H_TEMP
MOVFF R4L,R4L_TEMP
MOVFF R4H,R4H_TEMP
MOVFF R8L,R8L_TEMP
MOVFF R8H,R8H_TEMP
MOVFF R9L,R9L_TEMP
MOVFF R9H,R9H_TEMP
MOVFF FSR0L,FSR0L_TEMP
MOVFF FSR0H,FSR0H_TEMP
MOVFF FSR1L,FSR1L_TEMP
MOVFF FSR1H,FSR1H_TEMP
Hi E,
I presume this is ASM? I wish I could understand it.
I did find that those settings shouldn't be updated while an INTERRUPT is in play.
C.
 

ericgibbs

Joined Jan 29, 2010
18,766
hi C,
As you may know Oshonsoft when it complies a Basic program. it creates a ASM, LST and HEX files.
You don't need to understand that section of ASM, the Save System command generates that code.
Be aware that when using High and Low Interrupts that the Save System in High takes priority and will over write the values saved in the Low interrupt, if the High Int occurs while processing the Low Int code.
E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,724
hi C,
As you may know Oshonsoft when it complies a Basic program. it creates a ASM, LST and HEX files.
You don't need to understand that section of ASM, the Save System command generates that code.
Be aware that when using High and Low Interrupts that the Save System in High takes priority and will over write the values saved in the Low interrupt, if the High Int occurs while processing the Low Int code.
E
Hi E,
Am I correct that if LOW interrupt SAVE SYSTEM is running and saving variables, then HIGH interrupt SAVE SYSTEM may over write the LOW variables, even if they're not related?
C.
 
Last edited:

ericgibbs

Joined Jan 29, 2010
18,766
hi,
Yes, IF the High occurs during a Low Int routine that is running.
You can always save your known variables within the Low routine and restore them just before the Resume, don't use the Save System in Low Int.

What appears to be the problem with your Intr's .??

E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,724
hi,
Yes, IF the High occurs during a Low Int routine that is running.
You can always save your known variables within the Low routine and restore them just before the Resume, don't use the Save System in Low Int.

What appears to be the problem with your Intr's .??

E
Hi E,
Ok, on SAVE SYSTEM.

There's no problem yet, but I'm joining the shorter individual programs where I tested the modules ( GPS etc) and I'm getting mixed up with the big spaghetti program. I'll post ot once it's less tangled.
Thanks.
C.
 
Last edited:

jjw

Joined Dec 24, 2013
823
hi C,
As you may know Oshonsoft when it complies a Basic program. it creates a ASM, LST and HEX files.
You don't need to understand that section of ASM, the Save System command generates that code.
Be aware that when using High and Low Interrupts that the Save System in High takes priority and will over write the values saved in the Low interrupt, if the High Int occurs while processing the Low Int code.
E
I don't think that Oshonsoft overwrites the saved registers.

I tested a program with two different interrupts, one with high priority one with low priority.
The save system writes the registers to different addresses in each interrupt.
For example in high interupt vvff rol, rol_temp
in low interrupt vvff rol, rol_temp2
etc.
The same with resume in reverse order.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,724
I don't think that Oshonsoft overwrites the saved registers.

I tested a program with two different interrupts, one with high priority one with low priority.
The save system writes the registers to different addresses in each interrupt.
For example in high interupt vvff rol, rol_temp
in low interrupt vvff rol, rol_temp2
etc.
The same with resume in reverse order.
Hi J,
Thanks for the test.
Perhaps once I post the program, you could test it in the same way please.
This may save a discussion at this time.
C.
 

ericgibbs

Joined Jan 29, 2010
18,766
hi jjw,
The PIC d/s do say that the High could overwrite the Low Saved variables.
Maybe Vlad of Oshonsoft has written his complier so this does not happen.??
E
AA1 01-Oct-18 11.41.gif
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,724
Hi E and J,

That's seems good.
Am I correct that both HIGH INTERRUPT and LOW INTERRUPT don't affect each other?
Is it ok to use SAVE SYSTEM for each? Why save system?
C.
 
Last edited:

jjw

Joined Dec 24, 2013
823
Hi E and J,

That's seems good.
Am I correct that both HIGH INTERRUPT and LOW INTERRUPT don't affect each other?
Is it ok to use SAVE SYSTEM for each? Why save system?
C.
High priority can interrupt the low priority.
I am not sure, but I think that SAVE SYSTEM stores some Oshonsofts internal variables which are used in calculations +-*/ and floating point math.

If you don't make any calculations in the interrupt routine, the SAVE SYSTEM is not needed?
 

Thread Starter

camerart

Joined Feb 25, 2013
3,724
High priority can interrupt the low priority.
I am not sure, but I think that SAVE SYSTEM stores some Oshonsofts internal variables which are used in calculations +-*/ and floating point math.

If you don't make any calculations in the interrupt routine, the SAVE SYSTEM is not needed?
Hi J,
If I recall correctly, the interrupts, are for transmitting and receiving only, all calculations are in the MAIN LOOP.
C.
 
Top