CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Multi Thread application

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
noyz



Joined: 31 Jan 2009
Posts: 59

View user's profile Send private message

Multi Thread application
PostPosted: Tue Jul 07, 2009 12:08 am     Reply with quote

I want to make a program for PIC16F88.
Is there any way to monitor 2 inputs and give separated functions in
multi thread program?

The inputs may be given in the same time, or not..
The delay from one function must not affect the second input and
function. Something like 2 PICs in one.


Is this possible or do I have to make something with booleans and interrupts and the reading from input to be done one by one .. not both at the same time.
Ttelmah
Guest







PostPosted: Tue Jul 07, 2009 2:14 am     Reply with quote

Basically, yes.
You don't give enough description to be really 'sure', but typically (for example), you wll use a timer interrupt, for your timings/delays, and switch between two 'threads', based on ticks of this interrupt.
This is basically, what the RTOS functionality offers you, _but_ the standard implementation, may not have the accuracy and speed that you need.
Many millions of PIC projects exist doing things like this.
Now the limitation on whether it can be done, will come down to a series of parameters:
How fast must things be scanned?.
What accuracy is needed in timings?.
What actually needs to happen in the threads. In particular hardware events/timings?.
Remember that, until relatively recently, all PC's etc., were only single core machines, yet multi-threading, was common. However just how well it worked, was massively down to the writing of the OS itself, and the individual 'parts'. So there was the 'classic' in Windows, of an application, which sat polling the keyboard, using the DOS/BIOS calls, and could basically stop the machine, and other threads running. However conversely, well written applications co-exixted fine. _But_ in each case, when multi threading, you could not _guarantee_ that a particular thread would be running at an exact 'moment' in time. Provided a slight delay was acceptable though, and hardware events were handled by interrupts and the OS, you could run multiple threads fine.
Getting it to work well, is down to actually understanding the hardware requirements of each attached device, and the timing requirements of each task.
I doubt if I have a single commercial program written in the last ten years on the PIC, which does _not_ multi-thread to some extent.....

Best Wsihes
noyz



Joined: 31 Jan 2009
Posts: 59

View user's profile Send private message

PostPosted: Thu Jul 01, 2010 6:17 pm     Reply with quote

i had to count some time for several A pins. if the time is less than 300ms then start a function. else up PIN_B0 until release pin A1 for example.

my question is.. how is better to implement this
using interrupts ?
what else..
my program is working now i've made a lots of boolean and check them over the main while.

should i use PIN change interrupt but what happens if the number of pins used does not figure the maximum suport by INT_RB (i'm using pic16f88) from how i remember INT_RB - rb4-7 :-?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 01, 2010 7:09 pm     Reply with quote

Multi-tasking examples in the main forum archives:
http://www.ccsinfo.com/forum/viewtopic.php?t=17189
http://www.ccsinfo.com/forum/viewtopic.php?t=21260

RTOS examples in the Code Library forum:
http://www.ccsinfo.com/forum/viewtopic.php?t=39433
http://www.ccsinfo.com/forum/viewtopic.php?t=21407
Note: These RTOS programs are not the built-in CCS RTOS
that comes with PCWH, etc.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group