I reviewed the assembly output for one of my PIC projects using FC 6.1.1.0, specifically the code generated for a custom interrupt, and noticed that the GIE flag gets set before the interrupt is setup. This means that the code setting or intializing the interrupt runs after the global interrupt flag is set i.e. after all interrupts are enabled. This may cause some initial, sporadic and unexpected behaviour. Should this not be placed instead just at the end of setting up the interrupt right after the PIE is enabled for example?
I also checked similar code for some of the predefined interrupt sources, such as timer 0, and found that the GIE is handled as expected, so ti apperas that just the customs interrupt code is affected.
Is it possible to make a note of this and correct in future releases?
Custom interrupts enable GIE too early
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Custom interrupts enable GIE too early
Hello,
The custom interrupt code can be altered by you if you would like to change the order. Are you saying that the demo examples in the Wiki have the incorrect order?
I don't think there will be any massive problems that come from enabling the GIE first unless there are other interrupt flags that have been enabled elsewhere in your program.
The custom interrupt code can be altered by you if you would like to change the order. Are you saying that the demo examples in the Wiki have the incorrect order?
I don't think there will be any massive problems that come from enabling the GIE first unless there are other interrupt flags that have been enabled elsewhere in your program.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: Custom interrupts enable GIE too early
I agree with this 100%Benj wrote:Hello,
I don't think there will be any massive problems that come from enabling the GIE first unless there are other interrupt flags that have been enabled elsewhere in your program.
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Posts: 37
- Joined: Sun Mar 30, 2014 9:27 pm
- Has thanked: 10 times
- Been thanked: 10 times
- Contact:
Re: Custom interrupts enable GIE too early
Nothing massive just odd.
As a work around the first thing I do is clear the GIE flag then setup the interrupts and at the end re-enable GIE.
The code I was referring to is generated when one selects any of the predefined interrupt sources associated with the INT symbol. Drag the INT into your flowchart, double click on it, check the Enable interrupt radio button and the select the interrupt source from the drop down list Interrupt on. In this code the GIE is set right at the end after setting PIE.
As a work around the first thing I do is clear the GIE flag then setup the interrupts and at the end re-enable GIE.
The code I was referring to is generated when one selects any of the predefined interrupt sources associated with the INT symbol. Drag the INT into your flowchart, double click on it, check the Enable interrupt radio button and the select the interrupt source from the drop down list Interrupt on. In this code the GIE is set right at the end after setting PIE.