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

Capture Mode On PIC18F452

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



Joined: 06 Feb 2004
Posts: 26
Location: Curitiba, Brazil

View user's profile Send private message Visit poster's website

Capture Mode On PIC18F452
PostPosted: Thu Dec 02, 2004 6:46 am     Reply with quote

I hadnīt had the pleasure of using the PIC18F452īs Capture module until now, so I scanned through the postings on CCP to see the types of issues that I would run into. Now I have a question. Is it possible to capture the pulse width of Timer1 without physically connecting Timer1īs output to the capture input pin? If this is possible, how does the Edge Detector get triggered? After reading through the Capture/Compare section of the PIC18F452 data sheet I came to the conclusion that it was not possible measure Timer1īs pulse width without connecting it up physically, however there are several code postings here that imply it is.

Sorry for appearing to be dumb, but can anyone help me?

Thank you.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Thu Dec 02, 2004 8:31 am     Reply with quote

Are you driving timer1 externally?
Bill_Smith



Joined: 06 Feb 2004
Posts: 26
Location: Curitiba, Brazil

View user's profile Send private message Visit poster's website

PostPosted: Thu Dec 02, 2004 8:45 am     Reply with quote

Hi Mark,

No, I was intending on setting Timer1 to use Fclk/4.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Thu Dec 02, 2004 9:01 am     Reply with quote

Then what are you trying to measure?? Timer1 with no prescaler increments at the same rate as an instruction cycle. It is the unit of measurement for the capture port?
Bill_Smith



Joined: 06 Feb 2004
Posts: 26
Location: Curitiba, Brazil

View user's profile Send private message Visit poster's website

PostPosted: Thu Dec 02, 2004 10:36 am     Reply with quote

Hi Mark,

I was just trying to see if I understood what I reading here in the Forum, and from the Microchip data sheet about using the Capture function. I thought there might be a simple way, using only software to setup Timer1 as a free running clock generator, and measure itīs pulse width by capturing the timerīs count on the rising and falling edges and subtracting. I thought that I might be able to do this without having to make a external connection between the Timer and the Capture registers on my target board.

After reading the PIC18F452 data sheet it seemed that I indeed needed to drive one of the I/O pins at Timer1īs rate and connect this output to the CCP1 input pin in order to play with the module. However, I found several code examples here on the Forum that appear to be saying that you can simply setup Timer1 to run off the Fclk/4, set the Timer1 prescaler to whatever, and then setup CCP1 to capture Timer1īs count on each rising edge, and CCP2 to capture Timer1īs count on each falling edge. Then you subtract CCP1 from CCP2 to calculate the pulse width.

I had not used the function before, so I was just checking to see if anyone on the Forum with experience might be able to clear up my confusion.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Thu Dec 02, 2004 12:42 pm     Reply with quote

Quote:
I found several code examples here on the Forum that appear to be saying that you can simply setup Timer1 to run off the Fclk/4, set the Timer1 prescaler to whatever, and then setup CCP1 to capture Timer1īs count on each rising edge, and CCP2 to capture Timer1īs count on each falling edge. Then you subtract CCP1 from CCP2 to calculate the pulse width.

This is true but you are not measuring timer1's pulse width but rather some external signal. The width of the pulse is in timer1 increments. It is pointless to actually measure the width of timer1, you already know that base on the clock and prescaler nor would it be possible to do with the ccp module.

Quote:
After reading the PIC18F452 data sheet it seemed that I indeed needed to drive one of the I/O pins at Timer1īs rate and connect this output to the CCP1 input pin in order to play with the module.

No, just some square wave signal connected to one of the ccp pins.
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