Skip to main content
Associate II
February 7, 2024
Question

improving progam executiion speed

To improve the execution time of a program being run on the board 'Nucleo-439ZI' from the current 20 ms period to less than 1 ms [more than 20 times reduction]. To reduce the same, I tried to switch the clock frequency source of the timer to HSE (8 MHz) instead of the internal clock (32.768KHz) [That means 24 times higher frequency to improve system latency ]. However, some issues are observed when tried by clicking 'Resolve Clock Issues' could not be resolved.

 

How can I improve execution time from 20ms to 1 ms?

This topic has been closed for replies.

34 replies

Andrew Neil
Super User
February 7, 2024

@KumarTP wrote:

 some issues are observed when tried by clicking 'Resolve Clock Issues' could not be resolved.


Well, nobody can help you there without knowing what, exactly, those issues were!

 


@KumarTP wrote:

How can I improve execution time from 20ms to 1 ms?


first you need to know what's taking all the time!

If it's in busy-wait loops, or similar, then no amount of speeding up the clock is going to help.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
ST Technical Moderator
February 7, 2024

Hello @KumarTP 

Would you share your IOC file in .text format? or maybe a screenshot of your clock tree would be sufficient. 

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL
KumarTPAuthor
Associate II
February 7, 2024

Please find the below screenshots

KumarTP_0-1707300289873.png

 

KumarTP_1-1707300321752.png


 
64 KB of 113 KB

 

 

 

mƎALLEm
ST Technical Moderator
February 7, 2024

Screenshots not clear.. Please share better image resolution.

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Tesla DeLorean
Guru
February 7, 2024

Pretty sure it's not going to be running off the 32 KHz HSI source.

For order of magnitude improvements you might need to change your approach.

You have not articulated your problem well, or illustrated it clearly. Try harder.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
mƎALLEm
ST Technical Moderator
February 7, 2024

Meanwhile, I need to check internally if this constraint on min HCLK value makes sense and it is not a bug in CubeMx

 

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
mƎALLEm
ST Technical Moderator
February 7, 2024

Hi guys,

Normally and at least the MCU could start with HSI which is 16Mhz. To me 25MHz as minimum does not make sense. So it smells a bug in CubeMx.

Moreover in the datasheet in Table 25. "Typical and maximum current consumption in Run mode" 2MHz is there. 

SofLit_1-1707311476208.png

I'm raising the behavior internally to confirm the bug and fix it. I will come back to you for any feedback.

 

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Tesla DeLorean
Guru
February 7, 2024

MCU should clock down to DC.

Suspect the threshold instead relates to some other peripheral, perhaps clocked independently from 48 MHz, like USB, SDIO or CRYP

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
mƎALLEm
ST Technical Moderator
February 7, 2024

@Tesla DeLorean @waclawek.jan ,

Yes indeed .. I didn't notice that USB and ETH were enabled in the ioc file.

Thank you guys for pointing me this out :folded_hands:

@KumarTP You need to disable USB and ETH in your ioc file to reach lower frequencies, as these peripherals need at least 25MHz for HCLK to work correctly.

 

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Andrew Neil
Super User
February 7, 2024

@mƎALLEm wrote:

@KumarTP You need to disable USB and ETH in your ioc file to reach lower frequencies, as these peripherals need at least 25MHz for HCLK to work correctly.


But the goal was to speed things up - so the lower limit shouldn't be a problem to @KumarTP  ?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
mƎALLEm
ST Technical Moderator
February 7, 2024

Yes but, in the middle of the discussion he raised an issue when he switches to HSE (@8MHz) which is related to min HCLK clock.

But frankly from my side I didn't catch yet the problem from his first post (confused with the wording "timer" and internal clock at 32.768KHz).

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
mƎALLEm
ST Technical Moderator
February 7, 2024

Again the pictures you are sharing have poor resolutions we can't see what is going on. If you can't please share again the ioc file showing these warnings.

Please share readable images.

Also you can click on the boxes in RED to show the warning(s).

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
KumarTPAuthor
Associate II
February 8, 2024

Please find the clk settings.

 

LCE
Principal III
February 7, 2024

@KumarTP There are really some pros here at work to help you, but as they all pointed out, your basic problem description is still rather cryptic.

What do you exactly mean with "execution time", or of what?

So, which peripherals are you using?

Which clock speed do you need or expect, SYSCLK for the CPU, which for the peripherals? 

Note: for a few peripherals / applications HSI might be too inaccurate or jittery.

Tesla DeLorean
Guru
February 7, 2024

I wish someone could clearly articulate what the problem is here, and where the 32.768 KHz LSE (32 KHz of the LSI) would be involved.

TIM5 can be used to measure LSI/LSE, but not as a source

TIM11 can be used related to HSE_RTC (1 MHz)

Still have no-idea "what" is taking 20 ms, its relationship to the MCU clock, or if 1 ms is remotely realistic.

If it takes 20 ms at 168-180 MHz the F439 normally clocks, there's going to need to be a better explanation of the task being performed, perhaps from the driving requirement rather than the current deficient solution.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
LCE
Principal III
February 8, 2024

Sigh...

Now you post a pdf including another low resolution picture.

Which still shows that there might be some bad clock settings.

Start reading the datasheet and reference manual about possible PLL settings, compare to the code that Cube throws out.

And what about "execution time 20 ms"?

KumarTPAuthor
Associate II
February 8, 2024

The idea is to reduce program compiling time. Now it is taking 20ms, trying to reduce compiling time from 20ms to 1ms.( need to speed up ) And there are no other peripherals used.

mƎALLEm
ST Technical Moderator
February 8, 2024

Compilation time? or execution time??

Unfortunately you add more confusions than clarifying your expectations ..

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
LCE
Principal III
February 8, 2024

Maybe you give us some short description of what your "program" is doing.

And how are you measuring these obscure 20 ms ? 

Maybe you are using polling functions, while-tick-loops, ... so many things that can go wrong. But letting us guess doesn't help us help you. ;)