1 second interupt and prescaler question
1 second interupt and prescaler question
I am using a 16hv616 chip and I want to have a counter that increments every second. I plan to use the internal oscillator, but flow code 4 does not have internal as an option in chip configure options... Is this a problem?
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: 1 second interupt and prescaler question
Hello
PPP does list the internal oscillator as an option. Simply click Chip -> Configure in flowcode.
Next click the switch to expert mode button and you should be faced with the configuration settings for the 16F616 device.
Under Oscillator you have Internal RC No Clock or Internal RC Clockout.
Make sure that the code protect setting is set to off to avoid locking the program on your device.
PPP does list the internal oscillator as an option. Simply click Chip -> Configure in flowcode.
Next click the switch to expert mode button and you should be faced with the configuration settings for the 16F616 device.
Under Oscillator you have Internal RC No Clock or Internal RC Clockout.
Make sure that the code protect setting is set to off to avoid locking the program on your device.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: 1 second interupt and prescaler question
Ok, thanks.
So now for the prescaler question. At 4 Mhz, the counters run at 1 Mhz correct?
So now for the prescaler question. At 4 Mhz, the counters run at 1 Mhz correct?
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: 1 second interupt and prescaler question
Hello
If your prescaler is set to 1:1 then yes the PICmicro timers will run at 1/4 of the system clock, same as the program instruction rate.
If your prescaler is set to 1:1 then yes the PICmicro timers will run at 1/4 of the system clock, same as the program instruction rate.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: 1 second interupt and prescaler question
I was looking at the sample code for a 1 second timer.
In the example the clock is 19660800 Hz , the scaler is 256 and in the interrupt counts to 75 then adds to the second counter.
19660800 / 4 / 256 = 19200 hz that the interrupt is called. It runs 75 times before the second is advanced. How exactly is that 1 second of time? Can anyone explain how this works.
If I run at 4 mhz then how do I made a seconds counter with an interupt?
In the example the clock is 19660800 Hz , the scaler is 256 and in the interrupt counts to 75 then adds to the second counter.
19660800 / 4 / 256 = 19200 hz that the interrupt is called. It runs 75 times before the second is advanced. How exactly is that 1 second of time? Can anyone explain how this works.
If I run at 4 mhz then how do I made a seconds counter with an interupt?
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: 1 second interupt and prescaler question
Hello Dan
You forgot the timer register of 256.
19660800 / 4 / 256 / 256 = 75Hz
For the 4MHz crystal you could do the following.
4000000 / 4 / 64 / 256 = 61.0352
This seems to be the closest to a whole number you can get when using a 4MHz clock.
You forgot the timer register of 256.
19660800 / 4 / 256 / 256 = 75Hz
For the 4MHz crystal you could do the following.
4000000 / 4 / 64 / 256 = 61.0352
This seems to be the closest to a whole number you can get when using a 4MHz clock.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: 1 second interupt and prescaler question
This website is quite useful for calculating timer periods etc.
http://eng-serve.com/pic/pic_timer.html
http://eng-serve.com/pic/pic_timer.html
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: 1 second interupt and prescaler question
I knew I was missing something! Thank you I "got" it now.