View previous topic :: View next topic |
Author |
Message |
Dave_25152
Joined: 11 Dec 2010 Posts: 60
|
#use timer - error 100 |
Posted: Mon Oct 31, 2011 3:10 am |
|
|
Hello.
I'm using a PIC16F88 and want to use the function get_ticks ().
To use this function I need to use the "# use timer," but the compiler gives error.
I'm writing the following code:
Code: | #use TIMER (TIMER=0, TICK=1ms, BITS=8, NISR) |
"Error 100 - (...) timebase wrong for this timer"
My version of CCS is the 4.114.
thanks |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Mon Oct 31, 2011 4:05 am |
|
|
The error is telling you what is wrong.
Timer0, can't generate something even close to 1mSec tick (with your clock rate).
Last option also needs to be NOISR....
What is your clock rate?.
The #use delay 'clock' statement needs to be in front of this line (you would get an error if you haven't got this first).
What compiler version?.
What watchdog settings have you got? (remember the timer0 prescaler is shared with the watchdog).
Best Wishes |
|
|
Dave_25152
Joined: 11 Dec 2010 Posts: 60
|
|
Posted: Mon Oct 31, 2011 4:58 am |
|
|
Code: | #include <16f88.h>
#device adc=10
#use delay(internal=4Mhz)
#fuses INTRC_IO, NOWDT, PUT, NOMCLR, NOBROWNOUT, NOLVP, WRT, CPD
#use TIMER (TIMER=0, TICK=1ms, BITS=8, NOISR) |
He still does not work.
Compiler version: 4.114
Thanks |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Mon Oct 31, 2011 6:28 am |
|
|
OK.
That's a fault with 4.114 I'm afraid.
It'll complain if it can't do the exact rate. Latter compilers have this fixed. So you need to put a time interval in, that _is_ achievable with this timer, or use a timer that can achieve the rate you want.
#use TIMER (TIMER=0, TICK=1024uS, BITS=8, NOISR)
Best Wishes |
|
|
Dave_25152
Joined: 11 Dec 2010 Posts: 60
|
|
Posted: Mon Oct 31, 2011 6:58 am |
|
|
Good
The problem has been found.
As you have done to calculate the 1024uS?
Thank you! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Mon Oct 31, 2011 8:30 am |
|
|
Data sheet of the chip.
Timer is 8bit, divides by 256. Master clock/4, through a prescaler of 1,2,4,8,16,32,64 or 128. So times of:
256, 512, 1024, 2048, 4096, 8192, 16384, or 32768uSec supported.
Best Wishes |
|
|
Dave_25152
Joined: 11 Dec 2010 Posts: 60
|
|
Posted: Mon Oct 31, 2011 8:33 am |
|
|
Ahhhhh.
OK. I've got it. Thank you!
Best wishes to you. |
|
|
|