Searching \ for '[PIC] 16F627 TMR1 interrupt' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ints.htm?key=interrupt
Search entire site for: '16F627 TMR1 interrupt'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] 16F627 TMR1 interrupt'
2003\02\16@123652 by Kevinhoward

picon face
Hello all!
I have just started using the 16f627 and cannot get the tmr1 interrupt to
operate
I have set up as follows and assume the interrupt is 04h
Am I missing something totally obvious?--      HELP!

;set up interrupts
   clrf    status
   clrf    intcon
   clrf    pir1
   bsf status,rp0  ;switch to bank1
   movlw   b'00000001' ;enable tmr1 interrupt
   movwf   pie1
   bcf status,rp0  ;back to bank0
   bsf intcon,gie     ;enable global interrupt
     bsf  t1con,tmr1on     ;starts timer

Thanks in advance for your help.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\16@155901 by John Snider

picon face
<spam_OUTKevinhowardTakeThisOuTspamAOL.COM> wrote:
> I have just started using the 16f627 and cannot get the tmr1 interrupt to
> operate <snip>
> ;set up interrupts
> clrf    status
> clrf    intcon
> clrf    pir1
> bsf status,rp0  ;switch to bank1
> movlw   b'00000001' ;enable tmr1 interrupt
> movwf   pie1
> bcf status,rp0  ;back to bank0
> bsf intcon,gie     ;enable global interrupt
> bsf  t1con,tmr1on     ;starts timer
> ---------------------------------------------------
After setting the Timer1 (tmr1) interupt on the Peripheral interupt enable
register (PIE1), I think you have to enable Peripheral Ints on the Intcon
register,
bsf INTCON,PEIE ;turn on peripheral interupts
(see page 51 Table 7-2 on the Data Sheet)

For testing you can set TIMER1 to single step through it, (set value so
interupt occurs within reasonable time).
.....
clrf PIR1,TIM1IF        ;clear the timer1 overflow int flag
clrf TMR1H      ; set high byte on Timer1 to 0
movlw 0x4       ;4 cycles before int
movf TMR1L  ;set low byte on Timer1 to 4
bsf t1con, tmr1on       ;turn it on - keep stepping until interupt

Also, as the 16F627 has 4 banks, when switching banks maybe add the second
bit for clarity:
bcf status,rp1
bsf status,rp0  ; select bank 01
--
John Snider

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\16@162424 by Kevinhoward

picon face
JOHN,
            You are correct I did not enable the peripheral inputs (bsf
INTCON,PEIE)

It works fine now !!! THANK YOU FOR YOUR HELP.
regards
Kev
<snip>
{Quote hidden}

After setting the Timer1 (tmr1) interupt on the Peripheral interupt enable
register (PIE1), I think you have to enable Peripheral Ints on the Intcon
register,
bsf INTCON,PEIE ;turn on peripheral interupts

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\16@163058 by John Snider

picon face
I wrote:
> For testing you can set TIMER1 to single step through it, (set value so
> interupt occurs within reasonable time).
> .....
> clrf PIR1,TIM1IF        ;clear the timer1 overflow int flag
> clrf TMR1H      ; set high byte on Timer1 to 0
> movlw 0x4       ;4 cycles before int
> movf TMR1L  ;set low byte on Timer1
> bsf t1con, tmr1on       ;turn it on - keep stepping until interupt
> --------------------------------
DOH!
That should have been
...
movlw 0xFB ; set low byte on Timer1 to FB
movwf TMR1L ;set low byte on timer1
(timer obviously counts up to overflow, and I missed the W in movwf.....)

Sorry; John Snider

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\16@185419 by cdb

flavicon
face
You also need to enable bit6 in INTCON (PEIE)

Colin
--
cdb, .....bodgy1KILLspamspam@spam@optusnet.com.au on 17/02/2003

I have always been a few Dendrites short of an Axon and believe me it
shows.

Light travels faster than sound. That's why some people appear bright
until they speak!

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\16@195631 by Kevinhoward

picon face
Thanks to all!

Regards

Kev

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

More... (looser matching)
- Last day of these posts
- In 2003 , 2004 only
- Today
- New search...