|
|
View previous topic :: View next topic |
Author |
Message |
sureshkumar
Joined: 02 Oct 2013 Posts: 4
|
How can I make calculation for my desired delay in timers |
Posted: Wed Aug 20, 2014 11:00 am |
|
|
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: 19539
|
|
Posted: Wed Aug 20, 2014 11:47 am |
|
|
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. |
|
|
|
|
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
|