Nov 19, 2014 #1 G gstekboy Member level 5 Joined Oct 18, 2013 Messages 87 Helped 1 Reputation 2 Reaction score 1 Trophy points 8 Activity points 512 To get min .5ms delay. I chosen prescalar as 1:32 (The main frequency chosen as 4Mhz), what will be the TMR0 register value? Is it 0x64 or 0x63 !!
To get min .5ms delay. I chosen prescalar as 1:32 (The main frequency chosen as 4Mhz), what will be the TMR0 register value? Is it 0x64 or 0x63 !!
Nov 19, 2014 #2 esp1 Advanced Member level 1 Joined Sep 4, 2007 Messages 402 Helped 139 Reputation 278 Reaction score 140 Trophy points 1,323 Location England Activity points 3,392 hi, A 4MHz crystal will give an internal clock of 1MHz, ie: 1uSec Period. pre-scaling by 32 will give a 32uSec Period. So Tmr0 is 8Bit, ie:256 max, but 0.5mSec/32uSec = decimal 15.625.!! Check your calculations. E
hi, A 4MHz crystal will give an internal clock of 1MHz, ie: 1uSec Period. pre-scaling by 32 will give a 32uSec Period. So Tmr0 is 8Bit, ie:256 max, but 0.5mSec/32uSec = decimal 15.625.!! Check your calculations. E
Nov 19, 2014 #3 G gstekboy Member level 5 Joined Oct 18, 2013 Messages 87 Helped 1 Reputation 2 Reaction score 1 Trophy points 8 Activity points 512 esp1 said: hi, A 4MHz crystal will give an internal clock of 1MHz, ie: 1uSec Period. pre-scaling by 32 will give a 32uSec Period. So Tmr0 is 8Bit, ie:256 max, but 0.5mSec/32uSec = decimal 15.625.!! Check your calculations. E Click to expand... Sorry it is 5ms. So whether I need to chose ox63 or ox64 for TMR0 reg.
esp1 said: hi, A 4MHz crystal will give an internal clock of 1MHz, ie: 1uSec Period. pre-scaling by 32 will give a 32uSec Period. So Tmr0 is 8Bit, ie:256 max, but 0.5mSec/32uSec = decimal 15.625.!! Check your calculations. E Click to expand... Sorry it is 5ms. So whether I need to chose ox63 or ox64 for TMR0 reg.
Nov 19, 2014 #4 betwixt Super Moderator Staff member Joined Jul 4, 2009 Messages 16,623 Helped 5,158 Reputation 10,349 Reaction score 5,240 Trophy points 1,393 Location Aberdyfi, West Wales, UK Activity points 140,644 Nearest is 64 (decimal) which gives you 4.992mS. If you use 63 the period will be 5.024mS which has much larger error. If you want exactly 5mS use TMR1 pre-loaded with 60536 (0xEC78) and 1:1 prescaler. Brian.
Nearest is 64 (decimal) which gives you 4.992mS. If you use 63 the period will be 5.024mS which has much larger error. If you want exactly 5mS use TMR1 pre-loaded with 60536 (0xEC78) and 1:1 prescaler. Brian.