I use the new library built with version 2.0 of MPLAB-C18. I have many problems with interrupt flags (after 1 or 2 s, low and/or high interrupt are disable (GIEH or/and GIEL is set to 0 after a call to a salvo function), and i do not undestand why).

We are not aware of any problems with the MPLAB-C18 v2 libraries ... Salvo only controls the GIE bit.

If you can answer a few questions we may be able to figure out the problem:

1) Are you calling any Salvo services (e.g. OSSignalBinSem()) from within interrupts? This is allowed, of course.

2) Have you altered the default stack size?

Salvo alters the GIE bit in two main places -- OSDi() and OSEi() (used mainly in examples) and OSEnter|LeaveCritical() (used in many Salvo functions).

OSEnter|LeaveCritical() are in portmcc.h. OSEnterCritical() saves the GIE bit on the stack, and then sets GIE to 0. OSLeaveCritical() restores the GIE bit from what was saved on the stack. Both of these functions have been tested.

I suspect that if you are having trouble with interrupts, it may be i) something to do with the two different interrupt priorities that the PIC18 has, or ii) perhaps you've defined OSPRESERVE_INTERRUPT_MASK to FALSE or OSMPLAB_C18_STACK_SIZE to <= 256.

quote:I do not change the default stack size (size = 0x100).I do not understand why you want a stack > 256 bytes. Should i set stack size > 256 ?

No, I was just checking. A stack size of 256 should be OK.

quote:I try to protect the salvo services call by disable ISR before services call when call are made out of ISR (I read the Application note 9, and i think it is not nede for MPLAB-C18).

MPLAB-C18 is a stack-based compiler. Therefore you should not disable interrupts before calling a Salvo service in the background (task, etc.). I think this is your problem ... if you disable interrupts before a Salvo service call at the background level, then the service will not re-enable them when it is finished ...

quote:I use High level and low level ISR : form the high level ISR, i call sub routine using OSReadBinSem() and OSSignalSem(). From low level ISR, i call a sub-routine using OSTimer(). My code is as folliwing :

This may also be a problem. In the high/low priority interrupts mode, GIE is really GIEH (INTCON:7). This means that when Salvo services disable interrupts for a critical region, they only disable high-priority interrupts (low-priority interrupts are still enabled). In your case, this is a problem, because it means that OSTimer() may run in the middle of another Salvo service or function. If it ran in the middle of OSSched(), for example, that would be a problem ... Since OSTimer() does not affect interrupts, I do not think this will cause the problems you're seeing (interrupts not re-enabled) -- but it could cause other problems ...

You see, the libraries are built with control only of GIE/GIEH -- this means that if high/low interrupts are used then all Salvo services should be called from the high priority interrupt only. With the libraries we currently offer, you cannot call any Salvo services from the low-priority interrupt.

One thing you can do is set a simple flag in your lowLevelSwitch() and then call OSTimer() from your main loop (where OSSched()) is whenever that flag is set. As long as your tasks allow OSTimer() to be called fast enough, you won't have any problems ... something like this:

This issue is not a problem for Salvo Pro users, because they can redefine OSDi|Ei() and OSEnter|LeaveCritical() in portmcc.h to control the interrupt bits as they wish ... this is one advantage of a source-code build ... if my OSTimer() fix does not fit your application, you may want to consider upgrading to Salvo Pro.

OSPRESERVE_INTERRUPT_MASK must not be used with library builds -- please remove it from your salvocfg.h. See the User Manual for the limited number of configuration options that are allowed with library builds.

quote:Concerning GIEH and lower interrrupt, there is no problem : in fact when GIEH is reset low and high interrupt are disable. So if salvo librarie reset GIEH, it is OK.

I think there is a problem -- setting GIEH to 0 leaves low-priority interrupts enabled. Therefore an interrupts that calls OSTimer() (in your code) can occur while GIEH is 0. This will break a Salvo application ...

Does the problem happen if you do not call OSTimer() from the low-priority interrupt? If it still happens, then the problem may be in way Salvo is using the stack to save INTCON:GIE status.

Can you email us an MPLAB project that displays this problem in the MPLAB simulator? Then we can figure out why the stack has a problem ...

2) I do not change the default stack size (size = 0x100).I do not understand why you want a stack > 256 bytes. Should i set stack size > 256 ?

I try to protect the salvo services call by disable ISR before services call when call are made out of ISR (I read the Application note 9, and i think it is not nede for MPLAB-C18).

I use High level and low level ISR : form the high level ISR, i call sub routine using OSReadBinSem() and OSSignalSem(). From low level ISR, i call a sub-routine using OSTimer(). My code is as folliwing :