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.

Help needed - Newbie Simple delay routine PIC 16F84

Status
Not open for further replies.

bgs28

Newbie level 1
Joined
Jul 27, 2010
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Coventry
Activity points
1,290
Hi ,
Can anyone help?

Have recently started to look at PIC programming and looking at time delays.

I am struggling to understand some simple concepts it seems so cant make a start.

Can anyone please explain the following lines and how a 10ms delay is achieved.

wait10ms
movlw .256 - .10000/.256 ; set timer to 10ms delay
goto wait
wait50ms
movlw .256 - .50000/.256 ; set timer to 50ms delay
goto wait
wait
movwf TMR0
bcf INTCON, T0IF
clrwdt
btfss INTCON, T0IF
goto $-2
return

im struggling with the .256 - .10000/.256
and the $ -2 in particular

if anyone could explain how the delay is derived from these figures it would be a great help

thanks in advance

B Smyth
 

you need to read timr0 section of the datasheet.

in short, TMR0 is the count-up timer. .256-.10000/.256 load up the timer with an initial offset so that the timer will count up 10000/256 cycles before it overflows.

the prescaler is likely set at 256:1 and the crystal is 4Mhz. so each clock is 1us, and each prescaler is 256us, and since tmr0 takes 10000/256 prescaler output to overflow, each tmr0 overflow takes (roughly) 10000us = 10ms.

but you really need to read the datasheet.
 

software para generar rutinas PIC16Fxxx

aqui un software que uso mucho para crear rutinas de retardo sin usar timer.
**broken link removed**
solo elijan la frecuencia del cristal, escribir el tiempo en milisegundos, click en calcular ciclos y finalmente click en generar codigo.
solo copiar los archivos desde DEMORA hasta RETURN al mplab, declarar las variables que indica el picdelayer y listo.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top