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

Pulse Width Measuring w/ One CCP Pin

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



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

Pulse Width Measuring w/ One CCP Pin
PostPosted: Sat Sep 15, 2007 9:27 pm     Reply with quote

3.249
18LF6627 3.3V


Hello All,

Once again I've added functionality in hardware prior to understanding the requirements of the PIC. I was hoping to measure the duty cycle of 64uS period PWM signal (it's an RSSI reading). It appears that the 'desired' way is to use to CCPs to catch the rising and falling edge. I've only got one and I'd like to find a 'non-blocking' solution for measuring the pulse width.

My searching has shown me the ex_pulse.c solution (blocking). And other similar approaches.

Is there some way to change the CCP's detection from high_to_low to low_to_high midstream?

Or is there some other way to skin the cat?

Thanks,

John
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 16, 2007 12:01 am     Reply with quote

http://www.ccsinfo.com/forum/viewtopic.php?t=31470

However, these methods use interrupts, and that takes a
certain amount of time as overhead. Make sure the PIC
is running faster than 4 MHz (20 MHz would be much better).

You didn't say how short the pulse can be. If it's too short,
you're not going to be able to measure it, given the overhead
requirement to get in and out of an interrupt service routine.
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Sun Sep 16, 2007 12:35 am     Reply with quote

PCM,

Thanks. I didn't see that thread when I was searching. I will look at those examples in the morning.

Pulse width will be 0 or 15-62uS. So that should be enough time for the ISR?

Forgot to post processor speed: 40MHz.

John
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 16, 2007 12:55 am     Reply with quote

At 40 MHz with just the CCP1 interrupt running, the interrupt overhead
is about 4 us, not including the code in the isr. Lets say the isr code is
brief, and takes only 10 instruction cycles. That would give about 5 us
per interrupt. That's fast enough to work with a 15 us pulse, where an
interrupt occurs on each edge of the pulse.
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