Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC16F877A Timer0 delay problem?

Status
Not open for further replies.

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 !!
 

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

Sorry it is 5ms.

So whether I need to chose ox63 or ox64 for TMR0 reg.
 

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.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top