Sign in

username:

password:



Not a member?

Search piclist



Search tips

Subscribe to piclist



piclist by Keywords

12F675 | 16F628 | 16F84 | 16f877 | 16F877A | 16F88 | 18F458 | ADC | AVR | Bootloader | CAN | CCS | CRC | EAGLE | EEPROM | ICD | ICSP | IDE | JDM | LED | Macros | Microchip | MPLAB | PCB-CAD | PIC10F | Pic12f675 | PIC16F84 | PIC16F84A | PIC16F877 | PIC18 | PIC18F452 | PicBasic | PICC | PICSTART | PWM | RS-485 | RS232 | SMT | SPI | UART | USART | USB | Wireless | Wisp628 | Xilinx

Discussion Groups

Discussion Groups | Piclist | timer0 in pic16f84a

A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.

timer0 in pic16f84a - Nisheeth Gupta - Aug 1 12:33:00 2003


hi
hello
i have just started progrmming in assembly of pic . i
wrote a simple program for pic16f84a running at 4mhz . it has got a
timer routine which runs for 0.1 sec and sec1 routine which calls
timer routine 10 times..to waste 1 sec.....main program toggles led
once a second using sec1 routine...
i m unable to pinpoint the mistake in my program as it is compiling
successfully...
here goes the code
=======================
list p=16f84a
include "p16f84a.inc"
cblock 0ch
tenthsec,sec,tensec,min,mark250,mark200,mark2,ten
endc
#define led portb,0
org 00h
goto main

init
bsf status,rp0
movlw 00
movwf trisb
movlw 7
movwf option_reg
clrf tenthsec
clrf sec
clrf tensec
clrf min
movlw 250
movwf mark250
movlw 200
movwf mark200
movlw 2
movwf mark2
return

; for 0.1 sec at 4mhz pic should run 100,000 which
; is 250*200*2
timer
bcf status,rp0
movf mark250,w
subwf TMR0,w
btfss STATUS,Z
goto timer
movlw 250
addwf mark250

decf mark200,f
btfss STATUS,Z
goto timer
movlw 200
movwf mark200

decf mark2,f
btfss STATUS,Z
goto timer
movlw 2
movwf mark2
return

sec1
movlw 10
movwf ten
loop call timer
decf ten,f
btfss status,z
goto loop
return main
call init
bcf status,z
bsf led
call sec1
bcf led
call sec1
goto main
end
========================
in MPLAB IDE 6.3 i m unable to simulate timer0...its not incrementing
at all...is that a limitation of MPLAB IDE ?
i m unable to point out the mistake in last 2 days...
please find the clock.asm file attached
please help me out...

thanks in advance
nisheeth





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: timer0 in pic16f84a - Chad Russel - Aug 8 15:11:00 2003

Have you solved your problem yet? I may have some time this weekend.
Chad

--- Nisheeth Gupta <> wrote:
> hi
> hello
> i have just started progrmming in assembly of pic . i
> wrote a simple program for pic16f84a running at 4mhz . it has got a
> timer routine which runs for 0.1 sec and sec1 routine which calls
> timer routine 10 times..to waste 1 sec.....main program toggles led
> once a second using sec1 routine...
> i m unable to pinpoint the mistake in my program as it is compiling
> successfully...
> here goes the code
> =======================
> list p=16f84a
> include "p16f84a.inc"
> cblock 0ch
> tenthsec,sec,tensec,min,mark250,mark200,mark2,ten
> endc
> #define led portb,0
> org 00h
> goto main
>
> init
> bsf status,rp0
> movlw 00
> movwf trisb
> movlw 7
> movwf option_reg
> clrf tenthsec
> clrf sec
> clrf tensec
> clrf min
> movlw 250
> movwf mark250
> movlw 200
> movwf mark200
> movlw 2
> movwf mark2
> return
>
> ; for 0.1 sec at 4mhz pic should run 100,000 which
> ; is 250*200*2
> timer
> bcf status,rp0
> movf mark250,w
> subwf TMR0,w
> btfss STATUS,Z
> goto timer
> movlw 250
> addwf mark250
>
> decf mark200,f
> btfss STATUS,Z
> goto timer
> movlw 200
> movwf mark200
>
> decf mark2,f
> btfss STATUS,Z
> goto timer
> movlw 2
> movwf mark2
> return
>
> sec1
> movlw 10
> movwf ten
> loop call timer
> decf ten,f
> btfss status,z
> goto loop
> return > main
> call init
> bcf status,z
> bsf led
> call sec1
> bcf led
> call sec1
> goto main
> end
> ========================
> in MPLAB IDE 6.3 i m unable to simulate timer0...its not incrementing
>
> at all...is that a limitation of MPLAB IDE ?
> i m unable to point out the mistake in last 2 days...
> please find the clock.asm file attached
> please help me out...
>
> thanks in advance
> nisheeth

__________________________________





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: timer0 in pic16f84a - Chad Russel - Aug 9 15:59:00 2003

TMR0 works for me, but you do have other problems. I would reset to
bank 0 immediately after OPTION although I don't believe it affects
your program here.

Chad
--- In , "Nisheeth Gupta" <nisheeth_007@y...>
wrote:
> hi
> hello
> i have just started progrmming in assembly of pic . i
> wrote a simple program for pic16f84a running at 4mhz . it has got a
> timer routine which runs for 0.1 sec and sec1 routine which calls
> timer routine 10 times..to waste 1 sec.....main program toggles led
> once a second using sec1 routine...
> i m unable to pinpoint the mistake in my program as it is compiling
> successfully...
> here goes the code
> =======================
> list p=16f84a
> include "p16f84a.inc"
> cblock 0ch
> tenthsec,sec,tensec,min,mark250,mark200,mark2,ten
> endc
> #define led portb,0
> org 00h
> goto main
>
> init
> bsf status,rp0
> movlw 00
> movwf trisb
> movlw 7
> movwf option_reg
> clrf tenthsec
> clrf sec
> clrf tensec
> clrf min
> movlw 250
> movwf mark250
> movlw 200
> movwf mark200
> movlw 2
> movwf mark2
> return
>
> ; for 0.1 sec at 4mhz pic should run 100,000 which
> ; is 250*200*2
> timer
> bcf status,rp0
> movf mark250,w
> subwf TMR0,w
> btfss STATUS,Z
> goto timer
> movlw 250
> addwf mark250
>
> decf mark200,f
> btfss STATUS,Z
> goto timer
> movlw 200
> movwf mark200
>
> decf mark2,f
> btfss STATUS,Z
> goto timer
> movlw 2
> movwf mark2
> return
>
> sec1
> movlw 10
> movwf ten
> loop call timer
> decf ten,f
> btfss status,z
> goto loop
> return > main
> call init
> bcf status,z
> bsf led
> call sec1
> bcf led
> call sec1
> goto main
> end
> ========================
> in MPLAB IDE 6.3 i m unable to simulate timer0...its not incrementing
> at all...is that a limitation of MPLAB IDE ?
> i m unable to point out the mistake in last 2 days...
> please find the clock.asm file attached
> please help me out...
>
> thanks in advance
> nisheeth





(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )

Re: timer0 in pic16f84a - newbiesda - Aug 10 21:19:00 2003

I've noticed too that timer0 does NOT advance in MPSIM if the
prescaler is bypassed (1:1). But if the prescaler is assigned to
TMR0 (i.e. at least 1:2 or higher), then TMR0 increments.

I'm not sure why though. You may want to use the prescaler of 1:2 or
higher.
--- In , "Chad Russel" <chadrussel@y...> wrote:
> TMR0 works for me, but you do have other problems. I would reset to
> bank 0 immediately after OPTION although I don't believe it affects
> your program here.
>
> Chad
> --- In , "Nisheeth Gupta" <nisheeth_007@y...>
> wrote:
> > hi
> > hello
> > i have just started progrmming in assembly of pic . i
> > wrote a simple program for pic16f84a running at 4mhz . it has got
a
> > timer routine which runs for 0.1 sec and sec1 routine which calls
> > timer routine 10 times..to waste 1 sec.....main program toggles
led
> > once a second using sec1 routine...
> > i m unable to pinpoint the mistake in my program as it is
compiling
> > successfully...
> > here goes the code
> > =======================
> > list p=16f84a
> > include "p16f84a.inc"
> > cblock 0ch
> > tenthsec,sec,tensec,min,mark250,mark200,mark2,ten
> > endc
> > #define led portb,0
> > org 00h
> > goto main
> >
> > init
> > bsf status,rp0
> > movlw 00
> > movwf trisb
> > movlw 7
> > movwf option_reg
> > clrf tenthsec
> > clrf sec
> > clrf tensec
> > clrf min
> > movlw 250
> > movwf mark250
> > movlw 200
> > movwf mark200
> > movlw 2
> > movwf mark2
> > return
> >
> > ; for 0.1 sec at 4mhz pic should run 100,000 which
> > ; is 250*200*2
> > timer
> > bcf status,rp0
> > movf mark250,w
> > subwf TMR0,w
> > btfss STATUS,Z
> > goto timer
> > movlw 250
> > addwf mark250
> >
> > decf mark200,f
> > btfss STATUS,Z
> > goto timer
> > movlw 200
> > movwf mark200
> >
> > decf mark2,f
> > btfss STATUS,Z
> > goto timer
> > movlw 2
> > movwf mark2
> > return
> >
> > sec1
> > movlw 10
> > movwf ten
> > loop call timer
> > decf ten,f
> > btfss status,z
> > goto loop
> > return
> >
> >
> > main
> > call init
> > bcf status,z
> > bsf led
> > call sec1
> > bcf led
> > call sec1
> > goto main
> > end
> > ========================
> > in MPLAB IDE 6.3 i m unable to simulate timer0...its not
incrementing
> > at all...is that a limitation of MPLAB IDE ?
> > i m unable to point out the mistake in last 2 days...
> > please find the clock.asm file attached
> > please help me out...
> >
> > thanks in advance
> > nisheeth




(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )