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 CCS Technical Support

interrupt, prioritised task how?

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



Joined: 06 Nov 2005
Posts: 29

View user's profile Send private message

interrupt, prioritised task how?
PostPosted: Wed Feb 15, 2006 7:34 pm     Reply with quote

Hi all
not the simplest thing to explain but here goes.
Its a large project and I hope i have simplified the description without loosing vital information you may need.
PIC18F252
uses, i2c, rs232 (hardware), rs232(software), a/d inputs, digital i/o.

Problem summary:
Interlace a medium speed high priority interrupt driven process with a number of slow speed low priority process.

Initial Question:
how much code should one put into an INT?
(I've always tried to keep it as little as poss.)
(I dont want to put calls to subroutines inside the INT)

Background details:

Interrupt:
every 1ms, the timer2 INT routine advances a number of counters
when the samplecounter=sample rate (set to 2) a/d inputs must be sampled.(ie every 2ms)
these are then processed using a simple DSP algorithm.
Process time including a/d conversion, 100-250us.
I have plenty of "spare time".
The dsp is complex enough to call various sub routines and so is best not to place inside the INT ?

Other processes: Slow, low priority
handle incoming and outgoing rs232 port 1
handle outgoing rs232 on port 2
a2dcounter=a2d rate..sample other a/d inputs
12counter=i2c rate ervice i2c peripherals
service digital i/o.

Sampled A/d info:
Also worth noting the INT driven A/d sample, data is cyclic.
about 50ms (25samples) or intense data followed by 300ms of no data.
Once again there is plenty of time to "catch up" on things that need to be done. The 50-300 ratio however changes and thus I cant just be deaf during the break. I must check every 2ms!!

The important thing is that the 2ms intervals never get missed and are always 2ms as these are gated by various other things and used to indicate time elapsed etc.

Sounds like a normal INT driven type scenario? However the length of the DSP routine sitting inside the INT concerns me. Should it?
I thought of a 2 tiered task list system.
On INT it saves the address and data of the low priority task it was running.
it then sets a flag and "exits" the INT to the High Priority Task List.
if flag is set the HPTL samples the A/d and runs the dsp as required and then exits saying continue with the low priority tasks.

What almost worked:
I had it set up that the INT set a flag and then at the top of a task list the flag was tested and if set it would call the sample and DSP routine.
when the other tasks are idle this works fine.
however if another task is active even tho the INT is still interrupting and setting its flag the flag is not seen and acted upon until the "other" task is finished and execution has returned to the top of the task list. which of course is too late.

I might have to split the tasks up into smaller blocks maybe and hten use a state machine and change its states thus I could force it to the top of the list and thus always sample first. But the blocks would have to be in small less that say 1ms and doing that wont be easy.

At this point I think hmm Im going about this the wrong way, Im too deep in the forest to see the trees and cry help!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 15, 2006 8:31 pm     Reply with quote

See this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=17189

Also, if you have PCW or PCWH, look at the CCS RTOS.
mds



Joined: 06 Nov 2005
Posts: 29

View user's profile Send private message

PostPosted: Wed Feb 15, 2006 8:50 pm     Reply with quote

thanks reading thru the link
RE RTOS hmm yes i havent been game to play with that yet. any decent tutorials/getting started on that?
as I do have ccs PCWH
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