Ake Hedman wrote: > Jinx wrote: > >>> My fosc is 32 MHz. >>> By using a 32 bit prescaler i get 1MHz >>> =20 >> >> >> I think you mean divide by 32. And your instruction clock rate is >> only 8MHz, not 32MHz. A /32 pre-scaler reduces this to 250kHz >> (=3D 4us per count) >> >> =20 >> >>> I let the timer fire an interupt on overflow and reload it with=20 >>> 0xffff - >>> 0x3E8 >>> =20 >> >> >> So, your count rate is 250kHz and you're loading Timer0 with -1000d >> =3D a rollover rate of 1000*4us =3D 4ms, or x4 the time you expected >> >> =20 >> >>> But this give the wrong result. Instead if I change the prescaler to = 4 >>> the timing is OK >>> =20 >> >> >> I'm not sure if I've missed something in your description : >> >> A /4 pre-scaler puts the count rate at 2MHz =3D 0.5us/count. 1000 >> counts would =3D 0.5ms. It would appear to me that a /8 is needed >> to produce a 1MHz count rate =3D 1ms from a 1000 count >> =20 >> > Hi Jinx, > > I test it the following way: > > I count 30000 timer overflows for 30 seconds. If I use a prescaler=20 > value of 4 i get the correct 30 seconds. If set to 8 I would have=20 > found it to be acceeptable and probably deduced the fosc/4 timer input=20 > clock (which I missed) . But this is strange... > > Anyway thanks for your kind input Olin and Jinx. > > Regards > /Ake > Problem solved! Prescaler set to eight is fine. I just messed up in=20 another place of the code. Thank you again for your input Olin & Jinx. Regards /Ake --=20 --- Ake Hedman (YAP - Yet Another Programmer) eurosource, Brattbergav=E4gen 17, 820 50 LOS, Sweden Phone: (46) 657 413430 Cellular: (46) 73 84 84 102 Company home: http://www.eurosource.se =20 Kryddor/Te/Kaffe: http://www.brattberg.com Personal homepage: http://www.eurosource.se/akhe Automated home: http://www.vscp.org -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics