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

Elapsed Time

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



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

Elapsed Time
PostPosted: Sat Mar 09, 2013 6:24 am     Reply with quote

Dear Friends, I have a function where I have input on INT1. Now I need to check the elapsed time between two inputs on the same interrupt. How I can implement it because I have no idea from I can start.

Thanks
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

PostPosted: Sat Mar 09, 2013 6:51 am     Reply with quote

I found the solution. I used the get function

Code:
value=get_timer1();


from where I can know how I configured the Timer; which resolution from the .h file?
temtronic



Joined: 01 Jul 2010
Posts: 9167
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Mar 09, 2013 7:00 am     Reply with quote

The first place I'd look is in the EXAMPLES folder !

CCS kindly supplies a working program for you.

hint: 'stopwatch'.

probably 99% of the code required for 99% of the 'projects' can be found in the EXAMPLES folder....
that's just one of the benefits of using their compiler!

hth
jay
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

PostPosted: Sat Mar 09, 2013 7:10 am     Reply with quote

temtronics, I am dealing with ms and ns and not seconds. I saw the examples, that's why I came here
nurquhar



Joined: 05 Aug 2006
Posts: 149
Location: Redditch, UK

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

PostPosted: Sat Mar 09, 2013 7:20 am     Reply with quote

When you get it working for ns post the code. It will be interesting see how to accuratly handle the interrupt latency.
jeremiah



Joined: 20 Jul 2010
Posts: 1328

View user's profile Send private message

PostPosted: Sat Mar 09, 2013 12:42 pm     Reply with quote

Working in ns makes things very difficult. Even running a dsPIC at 80 MHz only gives an instruction clock period 25ns, so each instruction in code will take 25ns (or more). For ms timing, you might look at a chip with input capture on it. You can set it up to trigger and record a time stamp for you, giving you some leeway to do other things.

Most likely, a solution in ns is going to be something completely tailored to your setup so you are unlikely to find many solutions from others on that.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sat Mar 09, 2013 2:21 pm     Reply with quote

Quote:

ms and ns and not seconds.


what about the other lonely magnitude ??

are uSecs the orphans here ??? Very Happy Very Happy

Usecs and above you can resolve pretty well on a pic with a fast enough clock and capture / compare AND
depending on the range of time you want to measure -
by using more than one approach

but nano-secs ?? you will need significant EXTERNAL ($$) hardware design to
slip into that range of resolution, as a Pic alone is not gonna resolve that based on realistic Fosc values
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

PostPosted: Sat Mar 09, 2013 4:20 pm     Reply with quote

let keep it up to ms at the moment. When using the value=get_timer1() and I receive a value of 175, that means a value from 0-255? I can use the following formula to represnt the value to seconds:

Code:
 
255 = 13ms
175 = ?


13ms is the resolution of the Timer

thanks
temtronic



Joined: 01 Jul 2010
Posts: 9167
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Mar 09, 2013 5:36 pm     Reply with quote

Timer1 returns a 16 bit integer.

If you press F11 when your project is open, you'll get the 'CCS help' files...simply scroll down to get_timerx() in the builtin_functions list.

Without seeing your code as to PIC, clock source, timer1 setup we can't tell you exactly what the returned value relates to.

hth
jay
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sun Mar 10, 2013 1:31 pm     Reply with quote

what pic are you using ??
18Fxxxx ? 16Fxxxx ? other ?
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

PostPosted: Sun Mar 10, 2013 1:38 pm     Reply with quote

I am using the 18F4550 and the XTAL of 20MHz
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Sun Mar 10, 2013 2:28 pm     Reply with quote

aaronik19 wrote:
let keep it up to ms at the moment. When using the value=get_timer1() and I receive a value of 175, that means a value from 0-255? I can use the following formula to represnt the value to seconds:

Code:
 
255 = 13ms
175 = ?


13ms is the resolution of the Timer

thanks


I can't begin to understand what you're trying to say.

We need loads more information:-

1) Time range(s) to measure.
2) Required resolution(s).
3) Compilable code to test.
4) Compiler version.
5) ............

Mike
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