Dear FC9 team,
I'm testing interrupts with TMR1 in target PIC18F2331, and I found that in property window there isn't the rollover value to adjust the interrupt frequency.
But in the same window, for the TMR2 the rollover value is present.
What is the difference for this? Don't be supposed that for all Timers would be a rollover value to be adjusted by the user selection?
By the way, the TMR0 has the same missing rollover value issue.
Thanks for comment.
Best regards,
KikeRico
TMR0 rollover value property missing
-
- Posts: 21
- http://meble-kuchenne.info.pl
- Joined: Wed Aug 10, 2022 1:42 am
- Location: Mexico
- Has thanked: 2 times
- Been thanked: 7 times
-
- Matrix Staff
- Posts: 1280
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 170 times
- Been thanked: 287 times
Re: TMR0 rollover value property missing
Reading the datasheet, it looks like this device has a "period register" only on Timers 2 and 5, and this is used by the rollover value to adjust the interrupt frequency. Timers 0 and 1 do not have this feature.
-
- Posts: 21
- Joined: Wed Aug 10, 2022 1:42 am
- Location: Mexico
- Has thanked: 2 times
- Been thanked: 7 times
Re: TMR0 rollover value property missing
Hi Steve,
I have looked in datasheet, and for TMR0 it have period registers of 8-bit or 16-bit, And for TMR0 interrupt, it occurre when register roll-over from FF to 00 (8-bit mode) or from FFFF to 0000 (16-bit mode) For TMR1 is almost the same. Maybe the period registers for TMR0, TMR1 were not considered in FC interreuption window porting.
Do you think is possible to implement the roll-over (overflow) for TMR0, TMR1 in a C code module to adjust the interrupt frequency?
Best regards,
KikeRico
I have looked in datasheet, and for TMR0 it have period registers of 8-bit or 16-bit, And for TMR0 interrupt, it occurre when register roll-over from FF to 00 (8-bit mode) or from FFFF to 0000 (16-bit mode) For TMR1 is almost the same. Maybe the period registers for TMR0, TMR1 were not considered in FC interreuption window porting.
Do you think is possible to implement the roll-over (overflow) for TMR0, TMR1 in a C code module to adjust the interrupt frequency?
Best regards,
KikeRico
- p.erasmus
- Posts: 434
- Joined: Thu Dec 03, 2020 12:01 pm
- Location: Russia / Россия
- Has thanked: 104 times
- Been thanked: 88 times
Re: TMR0 rollover value property missing
Hi
If you need any other intterrupt time as given by the properties of the Interrupt Component you need to use the custom option and add C code to configure the Timer and set the Rollover yourself . If you select the Question mark in the property window the wiki will give you a full explenation of how the Interrupt Component functions,
here is the wiki for PIC Custom interrupts with and example for Timers
https://www.flowcode.co.uk/wiki/index.p ... -_PICmicro
In the standard properties of the Interrupt the component use the full range of the Timer Register that means it starts to count from zero(0) and at 65535 it rolls over and the Interrupt is triggered ,the time is based on your Clock frequency and the Timer pre-scaler value( it shows you the interrupt frequency) in the example below the clock is 19660800 and the pre-scaler is 16 now the Time = 1/frequency = 1/12000 = 83mSec. now if you change the prescaler the Interrupt frequency will change .example prescaler 64 then the Frequency is 300 again 1/300 = 333 mSec
Again if you would like to have a custom Timer Interrupt value (Time) then you need to select your own presaler value and set the Timer register at a preploaded value to achieve your required Time
Hope this clear your confusion with the Rollover value whih is essential the Timer register value as for PIC mcu's the Interrupt is fired or the Timer Roll over when the Timer Register reach the maximum value 256 for 8 bit and 65535 for 16 bit Timer modes
Note check your device datasheet as the newer pics had some register bit and names changed in order to specify the correct bits the example is based on the older PIC's be carefull with the names
If you need any other intterrupt time as given by the properties of the Interrupt Component you need to use the custom option and add C code to configure the Timer and set the Rollover yourself . If you select the Question mark in the property window the wiki will give you a full explenation of how the Interrupt Component functions,
here is the wiki for PIC Custom interrupts with and example for Timers
https://www.flowcode.co.uk/wiki/index.p ... -_PICmicro
In the standard properties of the Interrupt the component use the full range of the Timer Register that means it starts to count from zero(0) and at 65535 it rolls over and the Interrupt is triggered ,the time is based on your Clock frequency and the Timer pre-scaler value( it shows you the interrupt frequency) in the example below the clock is 19660800 and the pre-scaler is 16 now the Time = 1/frequency = 1/12000 = 83mSec. now if you change the prescaler the Interrupt frequency will change .example prescaler 64 then the Frequency is 300 again 1/300 = 333 mSec
Again if you would like to have a custom Timer Interrupt value (Time) then you need to select your own presaler value and set the Timer register at a preploaded value to achieve your required Time
Hope this clear your confusion with the Rollover value whih is essential the Timer register value as for PIC mcu's the Interrupt is fired or the Timer Roll over when the Timer Register reach the maximum value 256 for 8 bit and 65535 for 16 bit Timer modes
Note check your device datasheet as the newer pics had some register bit and names changed in order to specify the correct bits the example is based on the older PIC's be carefull with the names
Regards Peter - QME Electronics
-
- Posts: 21
- Joined: Wed Aug 10, 2022 1:42 am
- Location: Mexico
- Has thanked: 2 times
- Been thanked: 7 times
Re: TMR0 rollover value property missing
Hi
p.erasmus thanks a lot for the explanation, it was very useful
I have tried some code in custom interrupt property and is quite straight forward to implement. With this I can configure the TMRs as need for programming.
Best reagrds,
Enrique Arroyo.
p.erasmus thanks a lot for the explanation, it was very useful
I have tried some code in custom interrupt property and is quite straight forward to implement. With this I can configure the TMRs as need for programming.
Best reagrds,
Enrique Arroyo.
- p.erasmus
- Posts: 434
- Joined: Thu Dec 03, 2020 12:01 pm
- Location: Russia / Россия
- Has thanked: 104 times
- Been thanked: 88 times
Re: TMR0 rollover value property missing
Hi Enrique,
Note if you preload the Timer High and Timer low with a value from which it starts to count (not from zero) till roll lover you can get any time period you like .
Happy you got it going good luck
Note if you preload the Timer High and Timer low with a value from which it starts to count (not from zero) till roll lover you can get any time period you like .
Happy you got it going good luck
Regards Peter - QME Electronics