Pumpkin, Inc.

Pumpkin User Forums

Dealing with very fast interrupt

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

Dealing with very fast interrupt

Postby din » Mon Oct 27, 2003 7:06 am

Hi,

I am using Salvo for PIC MCU's.

My application uses a PIC16F877 at 20MHz. It has an external clock counter at 125kHz (meaning that an interruption occurs every 8us).
As I measure with the scope an interrupt latency of about 15us, it won't work.

I can add a prescaller on the input signal, and then the interrupt occurs "only" each 32us.

Is that possible to “stop” the RTOS during very critical action? If yes, how?

Have anyone in mind another way to solve this kind of interrupt latency problem?

Regards

Daniel

din
 
Posts: 7
Joined: Sat Oct 18, 2003 11:00 pm

Re: Dealing with very fast interrupt

Postby aek » Mon Oct 27, 2003 10:59 am

Hi Daniel.

In this case, with PIC16 + PICC, what you really need to do is completely remove the RTOS from the interrupt latency issue.

What I mean by that is use Salvo Pro (only -- can't do this in Salvo Lite or LE) to change the way the RTOS disables interrupts.

To do this, you do a source-code build, or create a custom library, where you redefine OSDi() and OSEi() to disable and enable only the interrupt source(s) that are directly related to Salvo.

E.g if the only Salvo service you call from an ISR is OSTimer(), and you're using TMR0 to generate that interrupt, you would change OSEi() from

code:
GIE = 1

(see salvoincsalvo.h) to
code:
T0IE = 1

in your project's salvocfg.h and re-build the entire project (including all of the Salvo source files). You'd do a similar change to OSDi().

What this does is change the way the RTOS controls interrupts in critical sections. Instead of disabling all interrupts, it only disables the interrupts it needs to -- i.e. those that have ISRs that call Salvo services.

Note that if you break this rule (e.g. if you add OSSignalSem() to a UART ISR), your code will break, because you will be entering one of Salvo's critical sections during a UART ISR. To fix, you'd have to expand what OSDi() and OSEi() do ...

Make sense?

With this approach, you will have 0 interrupt latency in a Salvo application.

Note that 8us @ 20MHz is only 40 cycles on a PIC16. I suspect you aren't even seeing the Salvo interrupt latency (which would be larger) -- you're probably seeing some overhead due to PICC's preamble and exit code in the ISRs. So also keep that in mind.

quote:
Is that possible to “stop” the RTOS during very critical action? If yes, how?
So the answer is no, you can't stop it, but if you reconfigure how it controls interrupts, and use that correctly, then the RTOS has no effect on unrelated ISR activity.

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

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

Re: Dealing with very fast interrupt

Postby aek » Mon Oct 27, 2003 11:01 am

Hi Daniel.

In case it's not clear ... I meant that you would add these entries to your project's salvocfg.h (Salvo Pro source-code build only):

#define OSDi() T0IE = 0
#define OSEi() T0IE = 1

There's no need in the Salvo PIC distribution to edit salvoincportpicc.h to achieve this ...

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

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

Re: Dealing with very fast interrupt

Postby aek » Tue Oct 28, 2003 7:43 am

Hi Daniel.

Note that since OSDi() and OSEi() will no longer control global interrupts, you'll need to explicitly enable them somewhere in your code ...

Once you're all set up to make this change, I recommend that you examine a Salvo functions's listing (e.g. OSSched()'s in sched.lst) to verify that it has in fact been reconfigured to do what you want it to do, and not controlling interrupts globally. You'll see the interrupt-control code at the beginning and end of the function.

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

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

Re: Dealing with very fast interrupt

Postby din » Tue Oct 28, 2003 12:22 pm

Thanks,

quote:

#define OSDi() T0IE = 0
#define OSEi() T0IE = 1

I'll try doing that tip.

Daniel

din
 
Posts: 7
Joined: Sat Oct 18, 2003 11:00 pm


Return to Coding

Who is online

Users browsing this forum: No registered users and 1 guest

cron