Pumpkin, Inc.

Pumpkin User Forums

Salvo + MPLAB-C18 v2

For issues specific to Microchip's PICmicro® MCUs, including compilers (e.g. HI-TECH PICC & PICC-18, Microchip MPLAB®-C18) and IDEs (e.g. Microchip MPLAB®).

Salvo + MPLAB-C18 v2

Postby Salvo Tech Support » Tue Jul 16, 2002 11:29 am

We have released an update to Salvo v3.0.4 for MPLAB-C18 v2 users.

If you are still using MPLAB-C18 v1, then you needn't do anything.

If you are using MPLAB-C18 v2, you must obtain new Salvo libraries that are compatible with Salvo and MPLAB-C18 v2.

Download the patches for Salvo Lite here or Salvo LE or Pro here. Unzip the libraries in the patches and copy them to salvolib.

------------------
--------
Salvo Technical Support
Please request all tech support through the Forums.

[This message has been edited by Salvo Tech Support (edited July 16, 2002).]

--------
Salvo Technical Support
Please request all tech support through the Forums.
Salvo Tech Support
 
Posts: 173
Joined: Sun Nov 19, 2000 12:00 am

Re: Salvo + MPLAB-C18 v2

Postby Benoit Braud » Wed Jul 24, 2002 10:52 am

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).

Are the libraries for MPLAB-C18 version 2.0 full tested ?


Benoit B.
Benoit Braud
 
Posts: 10
Joined: Wed Jul 03, 2002 11:00 pm
Location: Avrillé, France

Re: Salvo + MPLAB-C18 v2

Postby aek » Thu Jul 25, 2002 9:30 am

Hi Benoit.

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.

Regards,

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Salvo + MPLAB-C18 v2

Postby aek » Thu Jul 25, 2002 9:37 am

Hi Benoit.

I also did a quick test using the v2 libraries and salvodemod4sysed4free.pjt in MPLAB with an MPLAB-ICE2000.

It works fine, which means that GIE is being controlled correctly (d4 uses interrupts). You may want to use that project to compare against yours.

Regards,

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Salvo + MPLAB-C18 v2

Postby aek » Mon Jul 29, 2002 12:44 am

Hi Benoit.

quote:
I call any Salvo services from within interrupts :
-> OSSignalSem()
-> OSReadBinSem()
-> OSTimer()
That's OK.
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:

code:
for (;;) {
if ( flag ) {
disable_low_prio_ints;
flag = 0;
OSTimer();
enable_low_prio_ints;
}
OSSched();
}

where flag is set in lowLevelSwitch().

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.

Regards,

[This message has been edited by aek (edited July 29, 2002).]

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Salvo + MPLAB-C18 v2

Postby aek » Mon Jul 29, 2002 12:48 am

Hi Benoit.

One more thing:

quote:
My salvocfg.h is :
code:
#define OSUSE_LIBRARY TRUE
#define OSLIBRARY_TYPE OSL
#define OSLIBRARY_GLOBALS OSF
#define OSLIBRARY_CONFIG OST
#define OSLIBRARY_VARIANT OSNONE

#define OSTASKS 4
#define OSEVENTS 5

#define OSPRESERVE_INTERRUPT_MASK TRUE




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.

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Salvo + MPLAB-C18 v2

Postby aek » Mon Jul 29, 2002 8:23 am

Hi Benoit.

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 ...

Regards,

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Salvo + MPLAB-C18 v2

Postby aek » Mon Jul 29, 2002 8:26 am

Hi Benoit.

Try one more thing -- change all auto variables you may use in each task to static ones. If that fixes it, then I probably know what's wrong and we should be able to fix that fairly easily ...

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Salvo + MPLAB-C18 v2

Postby Benoit Braud » Mon Jul 29, 2002 8:36 am

Before your answer, i made new tests : my conclusion is that my main problem is on the stack.

After 2 or 3 execution of my 2 task, the stack pointer (FSR1) have a wrong value (FSR1 < at the stack address).

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.

If you have any idea from stack error and salvo library, thanks to give it to me.

Regards.

Benoit B.
Benoit Braud
 
Posts: 10
Joined: Wed Jul 03, 2002 11:00 pm
Location: Avrillé, France

Re: Salvo + MPLAB-C18 v2

Postby Benoit Braud » Mon Jul 29, 2002 11:56 am

Hi,

Answer to your questions :
1) I call any Salvo services from within interrupts :
-> OSSignalSem()
-> OSReadBinSem()
-> OSTimer()

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 :

void highLevelSwitch( void );
void lowLevelSwitch( void );

#pragma code highLevelInterrupt=0x0008
void highLevelInterrupt(void)
/*-------------------------------------------------------------
*/
{
_asm
goto highLevelSwitch
_endasm
}

#pragma code lowLevelInterrupt=0x0018
void lowLevelInterrupt(void)
/*-------------------------------------------------------------
*/
{
_asm
goto lowLevelSwitch
_endasm
}
#pragma code

#pragma interrupt highLevelSwitch save =INTSAVELOCS, section(".tmpdata")
void highLevelSwitch( void )
/*-------------------------------------------------------------
Switch
*/
{
if ( TMR3IF )
AIG_timer3_interrupt();

if ( CCP1IF )
TURB_ccp1_interrupt( );

if ( TMR1IF )
TURB_timer1_interrupt( );

}
#pragma code

#pragma interruptlow lowLevelSwitch save =INTSAVELOCS, section(".tmpdata")
void lowLevelSwitch( void )
/*-------------------------------------------------------------
*/
{
if ( TMR0IF )
TIM_timer0_interrupt();

}


TIM_timer0_interrupt() call OSTimer().
TURB_ccp1_interrupt( ) call OSReadBinSem() and OSSignalSem().

I link with the library : slc18sft.lib.

My salvocfg.h is :

#define OSUSE_LIBRARY TRUE
#define OSLIBRARY_TYPE OSL
#define OSLIBRARY_GLOBALS OSF
#define OSLIBRARY_CONFIG OST
#define OSLIBRARY_VARIANT OSNONE

#define OSTASKS 4
#define OSEVENTS 5

#define OSPRESERVE_INTERRUPT_MASK TRUE


Regards,


------------------
Benoit B.

Benoit B.
Benoit Braud
 
Posts: 10
Joined: Wed Jul 03, 2002 11:00 pm
Location: Avrillé, France

Next

Return to PICmicro MCUs

Who is online

Users browsing this forum: No registered users and 1 guest

cron