There seems to be an error in the Timer interrupt frequency calculation.
I created a small test program - using a pic16lf15313 running at 32MHz. I have a LED on a4 (with a current limiting resistor of course)
The Interrupt enable specifies a frequency of 1953Hz - but as can be seen from the check at the end - the frequency is ~8000Hz (actually it's its slightly > 8000 set check to 7800 - 8100 to light the LED!)
Modifying source to FOsc / 4 gives the same 'calculated' rate - and the correct rate in hardware.
Edit - it's probably just that fosc /hfintosc options shouldn't be offered?
Martin
PIC Timer interrupt calculation
-
- Valued Contributor
- Posts: 1454
- http://meble-kuchenne.info.pl
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 135 times
- Been thanked: 708 times
-
- Matrix Staff
- Posts: 1926
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 501 times
- Been thanked: 686 times
Re: PIC Timer interrupt calculation
Hi Martin,
Hmm that's strange maybe something for us to explore in the executable. Here is the XML from the definition file for timer 2 and it seems to be setting the clock divider (clkdiv) correctly to 0 when the selected source clock speed is unknown. Maybe Flowcode is incorrectly assuming a clkdiv of 0 is actually a clkdiv of 4.
Hmm even the clkdiv of 1 isn't working. Very odd I'll chase this up.
Hmm that's strange maybe something for us to explore in the executable. Here is the XML from the definition file for timer 2 and it seems to be setting the clock divider (clkdiv) correctly to 0 when the selected source clock speed is unknown. Maybe Flowcode is incorrectly assuming a clkdiv of 0 is actually a clkdiv of 4.
Hmm even the clkdiv of 1 isn't working. Very odd I'll chase this up.
Code: Select all
<option name='Clock Source Select' >
<entry name='Transition on T2CKI pin' clkdiv='0' value='T2CLKCON = 0;\n' />
<entry name='Internal clock (Fosc/4)' clkdiv='4' value='T2CLKCON = 1;\n' />
<entry name='Internal clock (Fosc)' clkdiv='1' value='T2CLKCON = 2;\n' />
<entry name='HFINTOSC' clkdiv='0' value='T2CLKCON = 3;\n' />
<entry name='LFINTOSC' clkdiv='0' value='T2CLKCON = 4;\n' />
<entry name='MFINTOSC 500KHz' clkdiv='0' value='T2CLKCON = 5;\n' />
<entry name='MFINTOSC 31.25KHz' clkdiv='0' value='T2CLKCON = 6;\n' />
<entry name='SOSC' clkdiv='0' value='T2CLKCON = 7;\n' />
</option>
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Matrix Staff
- Posts: 1465
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 204 times
- Been thanked: 347 times
Re: PIC Timer interrupt calculation
I've looked into this and it appears that the "clkdiv" override on the clock source entries in the FCD are totally ignored by Flowcode and instead the "master_divider" entry is used.
There is no simple fix. I'll add it to my list to investigate, and hopefully there will be a fix in a future release of Flowcode.
There is no simple fix. I'll add it to my list to investigate, and hopefully there will be a fix in a future release of Flowcode.
-
- Matrix Staff
- Posts: 1465
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 204 times
- Been thanked: 347 times
Re: PIC Timer interrupt calculation
A quick update on this. I have fixed this issue and it will be fixed once v10 has been released. We expect this release before the year end.