Pumpkin, Inc.

Pumpkin User Forums

Using Salvo with USBDriverService in ISR

If you can't make Salvo do what you want it to do, post it here.

Using Salvo with USBDriverService in ISR

Postby pkasturi » Tue Oct 30, 2007 1:12 am

Hi,

I am unable to create tasks when I call Microchip's USBDriverService() from either low/high ISR. I get multiple call graph errors for OSSaveRtnAddr, OSWaitBinSem, OSWaitEvent... functions.

I am using Hi-Tech's PICC-18 compiler and Salvo Lite OS. My OSLIBRARY_TYPE = SYSF; OSLIBRARY_CONFIG = OSA and OSLIBRARY_VARIANT = OSB and library = "sfp82lab.lib" library.

I can get my project to compile if I use #pragma interrupt_level 0 before main() and ISR(). However, I really do not like doing this.

I will appreciate any suggestions you can provide me in this regard.

pkasturi
 
Posts: 4
Joined: Mon Oct 29, 2007 11:00 pm
Location: Irvine, CA USA

Re: Using Salvo with USBDriverService in ISR

Postby aek » Tue Oct 30, 2007 1:17 am

Read http://www.pumpkininc.com/content/doc/manual/rm-picc18.pdf page 10 onwards and use the -a VARIANT library to allow you to do multiple call graphs.

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

(Edited to properly identify -a VARIANT)

[This message has been edited by aek (edited October 30, 2007).]

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

Re: Using Salvo with USBDriverService in ISR

Postby pkasturi » Tue Oct 30, 2007 2:36 am

Hi Andrew,

I have tried to compile with OSLIBRARY_VARIANT = OSA and library = "sfp82laa.lib". Even with this setting, I was getting multiple call graph errors for OSSaveRtnAddr, OSWaitBinSem, OSWaitEvent, OSInsPrioQ.

The only way I can get my project to compile is if I use "#pragma interrupt_level 0" before my high_isr and main(); I am calling OSCreateTask from main().

One interesting to note is that I do not have the multiple call graph issue if I call Microchip's USBDriverService() in the same while loop that contains OSSched(). I cannot imagine the USBDriverService() having any OS related calls.

pkasturi
 
Posts: 4
Joined: Mon Oct 29, 2007 11:00 pm
Location: Irvine, CA USA

Re: Using Salvo with USBDriverService in ISR

Postby aek » Tue Oct 30, 2007 2:46 am

It sounds like you've got a context switch (OS_WaitBinSem()?) inside an ISR -- that's not permitted.

Microchip's USB stuff will not have any (direct) ties to the OS.

I think I know what you're trying to do. Read the last couple of pages of http://www.pumpkininc.com/content/doc/press/pumpkin_supsi2005.pdf to see how to "move" a Salvo signaling call "up" from an ISR to the main() loop.

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

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

Re: Using Salvo with USBDriverService in ISR

Postby pkasturi » Tue Oct 30, 2007 3:09 am

I have stripped down my high_isr to barebones, and I do not have any OS calls here, at least to my knowledge. My high_isr goes like thus:

code:
#pragma interrupt_level 0
void interrupt high_isr(void)
{
if (0)
{
OSCreateBinSem(OSEBP(1), 0);
OSSignalBinSem(OSECBP(1));
}
if (USBIE && USBIF)
{
if (UCFGbits.UTEYE != 1)
{
USBDriverService();
}
USBIF = 0;
}
}

USBDriverService() is part of Microchip's USB framework.

Everything works fine if I move the USBDriverService to a polled scheme, something like:

code:
void main(void)
{
...
while (1)
{
...
if (UCFGbits.UTEYE != 1)
{
USBDriverService();
}
OSSched();
}
}

[This message has been edited by aek (edited October 30, 2007).]

pkasturi
 
Posts: 4
Joined: Mon Oct 29, 2007 11:00 pm
Location: Irvine, CA USA

Re: Using Salvo with USBDriverService in ISR

Postby aek » Tue Oct 30, 2007 3:16 am

You mean that it's only the call to USBDriverService() that moves, and the multiple callgraph error goes away?

That's very odd.

Stuff like OSWaitBinSem() (a function invoked only by the macro OS_WaitBinSem()) must have been called from multiple levels to generate the error you mentioned ...

I presume you're not using the new, Pro version of PICC-18?

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

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

Re: Using Salvo with USBDriverService in ISR

Postby aek » Tue Oct 30, 2007 3:18 am

You know, my guess is that it might still have something to do with Microchip's framework. Perhaps it (the framework) is causing multiple callgraphs, and the linker isn't reporting them correctly. Keep in mind that MPLAB C18 is a fully reentrant compiler, and if the USB stack is tied to it more than it's tied to PICC-18 (an overlay compiler), this might cause problems. But in general, Microchip has been good about making stuff like stacks to work in non-RTOS and RTOS applications.

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

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

Re: Using Salvo with USBDriverService in ISR

Postby pkasturi » Tue Oct 30, 2007 3:21 am

That is exactly true.

I am using Hi-Tech's PICC-18 standard version 9.50 PL3 compiler.

pkasturi
 
Posts: 4
Joined: Mon Oct 29, 2007 11:00 pm
Location: Irvine, CA USA

Re: Using Salvo with USBDriverService in ISR

Postby aek » Tue Oct 30, 2007 3:31 am

Then that's not the problem ... 9.50PL3 should work fine.

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

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

Re: Using Salvo with USBDriverService in ISR

Postby aek » Tue Oct 30, 2007 3:36 am

One more comment ...

I dunno why you can't solve the multiple callgraph issues, but I suspect you're going to get better performance my "boosting" the USB call up to the main loop instead of processing it in an ISR.

Why?

1) It's probably fairly deep, which means you're using up stack depth.

2) It's probably fairly long, which means you're holding off other ISRs.

3) While it doesn't seem to be true in your case, IF such an interrupt always triggers (e.g. via signaling an event upon which a task is waiting or (re-)starting a task) a task to run, the runtime performance will be nearly identical to if it all ran from inside an ISR. Not identical, but nearly so.

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

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


Return to Coding

Who is online

Users browsing this forum: No registered users and 4 guests

cron