CodyG
Newbie level 2
- Joined
- Dec 1, 2011
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- Ontario, Canada
- Activity points
- 1,299
Hello, I discovered these boards earlier this week and found it very useful, so thanks to everyone already!
I am having a hard time understanding timer1 for a PIC18F4520. I am running an 8MHz oscillator and I want to have it interrupt every 10 ms.
My understanding of this is that the timer would increment the counter (with a 1:8 prescaler) every 4uS:
Period = (1/(8MHz/4) x 8) =4uS
Using it in 16 Bit mode, the counter will count is 65,536 times before it reaches overflow, so I would be getting an interrupt every 262.144mS.
To get a 10 mS interrupt I only want the counter to count 10mS/4uS = 2500 times.
Do I just subtract 2500 from 65536 to get 63306 and place it in the TIMER1H and TIMER1L registers in order to get my required delay?
Thank you in advance.
I am having a hard time understanding timer1 for a PIC18F4520. I am running an 8MHz oscillator and I want to have it interrupt every 10 ms.
My understanding of this is that the timer would increment the counter (with a 1:8 prescaler) every 4uS:
Period = (1/(8MHz/4) x 8) =4uS
Using it in 16 Bit mode, the counter will count is 65,536 times before it reaches overflow, so I would be getting an interrupt every 262.144mS.
To get a 10 mS interrupt I only want the counter to count 10mS/4uS = 2500 times.
Do I just subtract 2500 from 65536 to get 63306 and place it in the TIMER1H and TIMER1L registers in order to get my required delay?
Thank you in advance.