PIC24FV32KA304 Interrupt frequency calculation

For general Flowcode discussion that does not belong in the other sections.
Post Reply
Jorg_Guldner
Posts: 50
http://meble-kuchenne.info.pl
Joined: Wed Dec 23, 2020 9:55 am
Been thanked: 4 times

PIC24FV32KA304 Interrupt frequency calculation

Post by Jorg_Guldner »

Hi,
is it possible to show the interrupt frequency ?



regards
Jorg
Attachments
Interrupt frequency.jpg
Interrupt frequency.jpg (32.97 KiB) Viewed 5329 times

Steve-Matrix
Matrix Staff
Posts: 1465
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 204 times
Been thanked: 347 times

Re: PIC24FV32KA304 Interrupt frequency calculation

Post by Steve-Matrix »

You have specified an external source for the clock. So Flowcode does not know what the actual speed of the clock will be and so cannot calculate the interrupt frequency. The "Clock Speed" value near the bottom of the page is the speed of the internal clock.

Jorg_Guldner
Posts: 50
Joined: Wed Dec 23, 2020 9:55 am
Been thanked: 4 times

Re: PIC24FV32KA304 Interrupt frequency calculation

Post by Jorg_Guldner »

Hi,
you know, that the clock is set to external by setup. The value which is normally used for internal calculation gets the quartz frequency. You always know too, if the "pll" is selected or not. All values for calculation are inside the program. Is it not possible?


Regards
Jorg

BenR
Matrix Staff
Posts: 1926
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 501 times
Been thanked: 684 times

Re: PIC24FV32KA304 Interrupt frequency calculation

Post by BenR »

Hi Jorg,

Steve is correct with the timer set to External mode it is expecting pulses on the T1CK pin to be used to clock the timer. As Flowcode doen't know what's external to this pin it cannot work out the timings for you.
Pins.jpg
Pins.jpg (98.25 KiB) Viewed 5191 times
Setting the clock source to one of the internal clocks will allow Flowcode to then know and sync the timings up with the MCU clock source and do the calculation.

Steve-Matrix
Matrix Staff
Posts: 1465
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 204 times
Been thanked: 347 times

Re: PIC24FV32KA304 Interrupt frequency calculation

Post by Steve-Matrix »

Looking at this in more detail, the datasheet says T1CON:TCS selects the source input and can be either "Internal (Fosc/2)" or "Timer1 clock source selected by T1ECS<1:0>". The latter has the following options:
  • 11 = Reserved; do not use
  • 10 = Timer1 uses LPRC as the clock source (fixed 31 kHz)
  • 01 = Timer1 uses External Clock from T1CK (see Ben's post)
  • 00 = Timer1 uses Secondary Oscillator (SOSC) as the clock source
Flowcode assumes when using the latter you will be using T1CK and so it is shortened to "External" in the option list.

When you dig into the SOSC clock source, things get complicated further.

As you can see, clocks and interrupt sources can be complex, and Flowcode does not always offer every solution in a neat way - especially when you consider the range of devices it supports. You can use your own C code to change the clock source in this register if you like. But then Flowcode cannot know the actual source of the clock.

As a convenience, the Interrupt Properties window calculates the actual interrupt frequency in the less complex cases. If you have clock settings that are more complex, then you will need to manually calculate the actual interrupt frequency and/or create some kind of "LED flasher" program that allows you to measure it for your settings.

Jorg_Guldner
Posts: 50
Joined: Wed Dec 23, 2020 9:55 am
Been thanked: 4 times

Re: PIC24FV32KA304 Interrupt frequency calculation

Post by Jorg_Guldner »

Hi,
I know that you could do many setups. It was a discussion to find a way for a workaround not to use an oscilloscope.
A complete setup of the oscillator and timer section would be good, but this would take a lot of time.

Excuse me for posting this thread in the bug area.
Jorg

medelec35
Matrix Staff
Posts: 1913
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 619 times
Been thanked: 644 times

Re: PIC24FV32KA304 Interrupt frequency calculation

Post by medelec35 »

As Flowcode was designed to not show external interrupt frequencies, I have move this to the General section.
Martin

Post Reply