It has plagued me for a long time. Why does the tim1 clock of stm32 go slowly?

Source: Internet
Author: User
During the use of stm32, tim1 timer is often found to be inexplicably slow.CodeI was afraid that the crystal oscillator would not be able to vibrate. I could not find any problems with the oscilloscope, but tim1 was slow. Later I tried to avoid using tim1. Today I am determined to find the cause again, finally, we found that it was caused by MDK optimization. 
If the level 2 (-O2) optimization level is used by default, check optimize for time and one elf section per function. tim1 slows down a lot and other timers are normal. 
Use Level 0 (-O0) optimization level, select optimize for time and one elf section per function 
Or use level 2 (-O2) optimization level. If you only select one elf section per function, tim1 can work normally. Although the problem can be solved, however, the differences between different optimizations have not been carefully studied. In the end, which part of the code is optimized by the compiler, which causes the tim1 timer to slow down? This remains to be further studied, now, you have to take a look at your projects.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.