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

external interrupts with RTOS

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



Joined: 21 Sep 2008
Posts: 7

View user's profile Send private message

external interrupts with RTOS
PostPosted: Sun Sep 21, 2008 4:46 pm     Reply with quote

Hi All

I am a little confused about the use of external interrupts while using a RTOS.

In my application I'd like to count an incoming pulse, but at the same time drive an LCD in response to a user input via buttons (and a couple of other minor things) - it seems like I finally have to use a RTOS. After a little reading, these are my thoughts:

1/ I would have to have the input state checked (polled) as a very quick to execute function. This would be set as a task with a rate of execution that would satisfy the maximum frequency of the pulsed input.

2/ If I were to just have this pulsed input on a pin that has an external interrupt, I could not actually use the interrupt because of the RTOS? I would normally use this approach if I was not going to use a RTOS.

3/ My understanding is that there is no other hardware on any of the PIC's that I can offload the pulse counting to - the input capture features are to count the pulse widths etc. Am I correct?


Any comments would be greatly appreciated

Many thanks
LiamLiam



Joined: 21 Sep 2008
Posts: 7

View user's profile Send private message

any ideas?
PostPosted: Wed Sep 24, 2008 6:04 am     Reply with quote

Hi again

sorry if I was a little vague with the question, does anybody have suggestions or even just comments on this application?

Many thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Sep 24, 2008 9:54 am     Reply with quote

First, I think hardly anyone on this forum uses the CCS RTOS.
That's because there are very few questions and/or answers on it.
Also, you only get the RTOS if you buy PCW, PCWH, etc.
You don't get the RTOS if you buy the command line compilers and
integrate them with MPLAB. So a lot of us don't have it.


If you have a problem with counting pulses, then we need to ask:

1. What device is providing the pulses ?

2. What's your purpose in counting these pulses ? Why are you doing it ?
What information do the pulses contain ? Are they encoded ?
ASCII ? Manchester ? Etc.

3. What is the frequency and duty cycle (or high and low times)
of the pulses ? What are the voltage levels ? Is this a rectangular
waveform, or is it sinusoidal ? Are the pulses spaced at specific
intervals ? What is the length of the interval ?
LiamLiam



Joined: 21 Sep 2008
Posts: 7

View user's profile Send private message

PostPosted: Fri Sep 26, 2008 9:05 am     Reply with quote

Thanks for the reply PCM programmer.

1/ The incoming pulse is simply a square wave from a flow sensor - from 0V-5V. I then put this through a potential divider to take it to 2.5V for the PIC. It has a duty cycle of 50%.

2/ The frequency of the pulses is directly proportional to the flow rate.

3/ The maximum frequency of this is 100Hz, with levels as descibed above. The minimum will be approximate 0.01Hz

All I need to do though is increment a 32 bit unsigned integer each time a rising edge appears. As I previously mentioned I would normally do this with a external interrupt however I am unsure if this is possible while using a RTOS.


I noticed that there was little discussion of CCS' RTOS on this forum too... do you have any personal experiences with any? any suggestions on a suitable RTOS for use with CCS C?

Many thanks

EDIT: FYI I am using the PIC24F256GB108
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Sep 26, 2008 11:22 am     Reply with quote

Quote:
All I need to do though is increment a 32 bit unsigned integer each time a rising edge appears.

I don't know why you need a 32-bit counter when your highest clock
rate is 100 Hz. In one second, the counter will only count 100 clocks.
Compared to that, the capacity of a 32-bit variable is huge.


Quote:
I am using the PIC24F256GB108

On 16F and 18F PICs, Timer1 can be used as a 16-bit counter with an
external clock. I don't know anything about the 24F PICs, and I don't
have the compiler for those PICs.


Quote:

The incoming pulse is simply a square wave from a flow sensor - from
0V-5V. I then put this through a potential divider to take it to 2.5V for the PIC

Is the PIC running at 3.3v ? If so, 2.5v would work on a TTL-level input
pin, but not on a Schmitt trigger input. Check the PIC data sheet in the
"overview" section and the electrical section to verify the required input
levels. However, my knowledge here only applies to 18F PICs and
below. I don't really want to get involved with 24F and above.
LiamLiam



Joined: 21 Sep 2008
Posts: 7

View user's profile Send private message

PostPosted: Tue Sep 30, 2008 5:17 am     Reply with quote

This counter will never be reset - so it will be greater than 65K. I will periodically back this value up to EEPROM.

The PIC / the hardware / levels and interfacing is all sorted, this isn't part of the question. I can easily implement what I want, although without a RTOS, simply with an external interrupt set to trigger from low to high.

My question is how best to integrate this functionality with a RTOS, I was hoping somebody with some RTOS experience could shed some light on how best to achieve this.

thanks for your replies.
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