maximum isr interupt timer on pic

Status
Not open for further replies.

mgbglasgow

Junior Member level 1
Joined
Jun 15, 2011
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,508
hi,

im using 16f1827 pic, and im trying to create an isr with 1 second cycle, i have 4mhz clock, can this be achieved readily with either timer 0 (8 bit) or timer1(16 bit) using prescalers, from what i have worked out so far longest delay i can get is 524ms? is this correct, ? how to fix? (change clock to 1mhz?)

sb

- - - Updated - - -


or can i use timer2? prescale and postscale options available, i read the datasheet,,,
 

Simply use a counter with a 500 ms Timer interrupt. You have to use 16 bit Timer1. On every 500 ms timer interrupt a counter is incremented. If counter value is 2 then 1000 ms has elapsed.

To get the required Timer Initialization code you can use mikroElektronika Timer Calculator windows application.
 

Timer Delay Calculations:
* 1. Timer Frequency Ftimer = Fcy. ( Fosc and Fcy are different check data sheet)
* 2. Using a Prescalar then
* Ftimer = Fcy / scalar value
* 3. Time Interval Ttimer = 1/Ftimer
* 4. To calculate the value to be filled in Timer rolling over
* register to generate x sec delay :
* No of count for sec delay = x sec / Ttimer // number to be entered in Period register !


You adjust the scalar value to get the correct timer delay u required if goes out of range.E.g for 16 bit controllers 0x0000 to 0xffff is range.
 


The values that you must load to blink 10 times a second in the ISR at 4MHz crystal


Code:
   BCF PIR1, TMR1IF ; Clear Timer1 Interrupt Flag

MOVLW 0x80 ; Since doing key inputs, clear TMR1

MOVWF TMR1H ; for 1 sec overflow.
 
Last edited:

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…