Pumpkin, Inc.

Pumpkin User Forums

Interrupt Handling Semaphores?

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

Interrupt Handling Semaphores?

Postby Steve Clauter » Sun May 12, 2002 8:56 am

Hello,

I'm just getting started with my first Salvo program of my own making. Basically I've got a C program to take data which I get from an interrupt and store the data in a virtual LCD. That is an LCD built in memory with a few bytes for cursor position and mode.

So I've got an interrupt routine that gets a byte of data, roughly every 1msec, and "signals that new data is available with a semaphore", all in the interrupt routine. I think that's the right way to say it. Anyway is that a good thing to do? Or should I make some other event to signal the Virtual LCD task that new data is available?

Thanks for any assistance.

Steve

Steve Clauter
 
Posts: 4
Joined: Thu Jan 17, 2002 12:00 am
Location: Tempe, Arizona, USA

Re: Interrupt Handling Semaphores?

Postby aek » Mon May 13, 2002 6:59 am

Hi Steve.

Using a BinSem (not a Sem) is a perfectly valid way to do what you propose. At 200ns per instruction cycle, inerrupts every 1ms signaling that new LCD data is available will work fine.

Please Note:

The one distinct advantage of signaling directly from the ISR is that the order of signaled events will be preserved -- i.e. if you're waiting for two interrupt-driven events to happen, then the events will be processed in the order they occur.

The only disadvantage is that OSSignalBinSem() does take a while, and may adversely impact an extremely time-critical ISR. But in general, that won't be an issue.

Calling Salvo routines from ISRs on the PIC using the PICC compiler requires that you do things in a certain manner (I'm assuming you're doing a library build). You must use OSProtect() and OSUnprotect() at the background/task level, and you must deal with the issue of multiple call graphs properly by ensuring that, say, OSCreateBinSem() and OSSignalBinSem(), are each called from both the background and foreground levels (assuming you're using an a-variant library, e.g. slp42Caa.lib). Please see AN-8 and AN-9 for more information on these issues.

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

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

Re: Interrupt Handling Semaphores?

Postby Steve Clauter » Mon May 13, 2002 8:58 am

Hello Andrew,

Thanks for such an informative reply. Please allow me to ask one more question....Instead of just using a Binary Semaphore could I just past the data as a Message Semaphore? In that case, the C task would just handle new data directly when it was available instead of having to use the Binary Semaphore. Or do you think the ISR timing would suffer too much if I utilized a Message Semaphore?

Best Regards,
Steve

PS & BTW I will be attending the Microchip Masters Conference in July and should have one of these widgets working by then. Perhaps we could meet at that time. Within the next year I will be migrating to the PIC18 series as things are getting pretty aggressive.

Steve Clauter
 
Posts: 4
Joined: Thu Jan 17, 2002 12:00 am
Location: Tempe, Arizona, USA

Re: Interrupt Handling Semaphores?

Postby aek » Tue May 14, 2002 7:49 am

Hi Steve.

Yes, you could pass it as a message, too, and that would be cleaner. The ISR timing won't be too different.

Regards,

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

-------
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 2 guests

cron