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

How 2 Display Switching frequency?

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



Joined: 09 Oct 2007
Posts: 62

View user's profile Send private message

How 2 Display Switching frequency?
PostPosted: Fri Nov 02, 2007 9:16 am     Reply with quote

I've done multiple searches. I'm using a PIC16F690.

I believe my frequency current is:

#use delay(clock=4000000)

but can I display that in real time over RS232? Thank you all. Smile
Ttelmah
Guest







PostPosted: Fri Nov 02, 2007 10:52 am     Reply with quote

The only way for the chip to actually be able to detect it's own frequency, is if it has another clock source. If (for instance), you have an external 1/sec sgnal on a pin, then you can (crudely), count the number of instructions between the pin changing, or (more accurately), use a CCP module to count the clock pulses between edges.
You can't work out the frequency, without a second reference (just as, you cannot tell how 'high' you are, without some baseline to compare 'height' to). If using an external serial port, then you could generate a good estimate (if you know the baud rate of the port), by using the bit width as your reference. However at the end of the day, if you are able to send serial data, your internal oscillator frequency must be close to 'right'.

Best Wishes
amcfall



Joined: 20 Oct 2005
Posts: 44

View user's profile Send private message

PostPosted: Fri Nov 02, 2007 12:45 pm     Reply with quote

I am a bit confused as to what you are trying to accomplish. As said above, you pretty much have to know what frequency you are running at to do any serial communications. If you don't know what frequency you are running at, how are you going to send any data out the serial port?

Avery
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Sat Nov 03, 2007 9:18 am     Reply with quote

Perhaps what you are looking for is a preprocessor statement like __DATE__
only for the clock instead of the DATE or a getenv(string) that would return the clock value in #use delay(clock=40000000). Your code would then have the compile time value of your clock frequency. getenv () makes a lot of values available but it doesn't make the clock value available. Even if available it wouldn't actually measure the frequency just report what you specified at compile time.
Ken Johnson



Joined: 23 Mar 2006
Posts: 197
Location: Lewisburg, WV

View user's profile Send private message

PostPosted: Sat Nov 03, 2007 9:27 am     Reply with quote

From the V4.060 help file, getenv("CLOCK") returns the MPU FOSC


Ken
ThomasC



Joined: 09 Oct 2007
Posts: 62

View user's profile Send private message

PostPosted: Mon Nov 05, 2007 8:45 am     Reply with quote

amcfall wrote:
I am a bit confused as to what you are trying to accomplish. As said above, you pretty much have to know what frequency you are running at to do any serial communications. If you don't know what frequency you are running at, how are you going to send any data out the serial port?

Avery


It's a program designed for one of our customers. They will only be using only hyper terminal to interact and control the pic.
amcfall



Joined: 20 Oct 2005
Posts: 44

View user's profile Send private message

PostPosted: Mon Nov 05, 2007 9:00 am     Reply with quote

ThomasC wrote:
amcfall wrote:
I am a bit confused as to what you are trying to accomplish. As said above, you pretty much have to know what frequency you are running at to do any serial communications. If you don't know what frequency you are running at, how are you going to send any data out the serial port?

Avery


It's a program designed for one of our customers. They will only be using only hyper terminal to interact and control the pic.


Not quite what I meant, let me rephrase:

Why do you need to do this? Even if you switch frequency I would think that you will always know what frequency you are running at or you would not be able to setup your USART to talk to the outside world. So, when you switch frequencies and setup your oscillator you would just change the value of a variable that holds your current speed. I'm just wondering out loud here, I feel that I'm missing a part of the 'why'.

Avery
ThomasC



Joined: 09 Oct 2007
Posts: 62

View user's profile Send private message

PostPosted: Mon Nov 05, 2007 1:33 pm     Reply with quote

Embarassed Sorry, I confused the clock speed with the external/internal oscillator/RC oscillator connection (RA5/CLKIN).

I would like to display input from pin RA5 on the pic16F690. Thanks.
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