You forgot the prescaler:Toley wrote:I believe the soft is correct. Timer1 is a 16bits counter, if you are running at 8MHz it will increment every 0.5us. For 100ms it will need 200 000 tick this is over 16 bits.
200000 / 4 = 50000
TMR1 preload = 65536 - 50000 = 15536
v2.00 will give you 15535 and complain about the difference between calculated and entered time value although it is obvious that there should be no difference. This is why I suspect that integer math was not used in the calculation. At least, it is very easy to determine the limits, i.e. the min and max interrupt time based on MCU clock and available prescaler and postscaler values:
Code: Select all
TIME = COUNT * (4/Fosc) * PS
Code: Select all
MIN_TIME = 1 * (4/8000000) * 1 = 0.5 us
MAX_TIME = 65536 * (4/8000000) * 8 = 262.144 ms
1. Choose PIC18, 8 MHz clock, Timer0
2. Enter 1000 seconds as interrupt time and press calculate. You will get a popup saying that there is no solution which is OK
3. Enter 1 second and press calculate. You will get the solution
4. Now enter 1000 seconds again and press calculate: You will also get the solution along with some strange value for the prescaler (1:0) and a warning that difference is ~999 seconds or 99.9%.
In my opinion, timer is a generic, architecture independent concept, determined by simple set of variables (size, frequency, prescaler, postscaler etc.) governed by integer math rules and every calculator application should be coded with these things in mind. I might even create one if I get some spare time
Regards