|
|
View previous topic :: View next topic |
Author |
Message |
thiaguetz
Joined: 03 Feb 2004 Posts: 12 Location: Brazil
|
0,5s Timer |
Posted: Sat Mar 12, 2005 7:11 pm |
|
|
Hi folks,
I would like to know if exist a way to improve the precision in the following code:
PS.: When my timer reach more than 6 secods, it begin floating some miliseconds.
Thanks!
Code: |
#include <16f628.h>
#fuses INTRC,NOWDT,PUT,NOMCLR,NOPROTECT,NOCPD,BROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=19200, parity=N,xmit=PIN_B2,rcv=PIN_B1)
int8 counter;
#define TICK 7,62939453125
#INT_TIMER1
void clock_isr()
{
if(--counter==0)
{
counter = TICK;
}
}
void main()
{
counter = TICK;
setup_timer_1(T1_INTERNAL | T1_DIV_BY_1);
set_timer1(0);
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);
while (true)
{
}
} |
|
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Sat Mar 12, 2005 7:36 pm |
|
|
Go search the code archive posts. I believe it was Neutone (sorry if I'm giving credit where credit is not due) that posted some nifty stuff for zero-drift timing. _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
future
Joined: 14 May 2004 Posts: 330
|
|
Posted: Sun Mar 13, 2005 12:09 am |
|
|
#define TICK 7,62939453125 is a float number.
int8 counter; // is an integer
counter = tick; // counter is 7 now
I think you must rethink what you are trying do achieve. |
|
|
|
|
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
|