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

How can I make calculation for my desired delay in timers

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



Joined: 02 Oct 2013
Posts: 4

View user's profile Send private message

How can I make calculation for my desired delay in timers
PostPosted: Wed Aug 20, 2014 11:00 am     Reply with quote

Hello All,

How can I make calculation for my desired delay in timers.

I am using 20mhz external Crystal,PIC16F877A. CCS C V4.130.

I was read lot of examples and forum results about timers. But I am still confusing about the timer calculations.

If I am using internal clock and my desired time delay is 2 seconds.
How can I calculate ?.

If I am using external clock.(External clock means My Crystal ?.) How can I calculate ?.

Please make a simple code with command lines and Formula for me.
Code:

#include <16F877A.h>
#FUSES HS,NOWDT
#use delay(clock=20mhz)

#INT_RTCC
void clock_isr(){
          output_toggle(PIN_C5);
}

void main()
{
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_8);
   enable_interrupts(INT_RTCC);
   enable_interrupts(GLOBAL);

  while(true){
      output_low(PIN_D0);
      delay_ms(1000);
      output_high(PIN_D0);
      delay_ms(1000);
    }

}


What is here I am exactly done ?.
_________________
Thanks and Regards
Sureshkumar.
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Wed Aug 20, 2014 11:47 am     Reply with quote

Start with the data sheet.

Read it.

Then get the timer tutorials 51682A, and 51702A.

Your questions are directly answered in here.

For instance, the one on timer 'source', is the paragraph entitled 'Selecting the Timer0 Source (see Figure 1-5)'.

Read all three documents at least three times, and if you still can't see what you have to do, come back.

However 'hint', to give a delay of 2 seconds, the timer will have to be fed off a much slower clock than your CPU clock.
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