{"id":12838,"date":"2025-04-18T19:55:48","date_gmt":"2025-04-18T11:55:48","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/12838.html"},"modified":"2025-04-18T19:55:48","modified_gmt":"2025-04-18T11:55:48","slug":"stm32%e5%85%ab%e8%82%a1%e3%80%905%e3%80%91-tim%e5%ae%9a%e6%97%b6%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/12838.html","title":{"rendered":"STM32\u516b\u80a1\u30105\u3011----- TIM\u5b9a\u65f6\u5668"},"content":{"rendered":"<h3>1. TIM\u5b9a\u65f6\u5668\u5206\u7c7b<\/h3>\n<p>STM32 \u7684\u5b9a\u65f6\u5668\u4e3b\u8981\u5206\u4e3a\u4ee5\u4e0b\u51e0\u7c7b&#xff1a;<\/p>\n<ul>\n<li>\u9ad8\u7ea7\u5b9a\u65f6\u5668&#xff08;Advanced TIM&#xff0c;TIM1\/TIM8&#xff09; \u5177\u5907 PWM \u751f\u6210\u3001\u6b7b\u533a\u63a7\u5236\u3001\u4e92\u8865\u8f93\u51fa\u7b49\u9ad8\u7ea7\u529f\u80fd&#xff0c;\u9002\u7528\u4e8e\u7535\u673a\u63a7\u5236\u548c\u529f\u7387\u8f6c\u6362\u5e94\u7528\u3002<\/li>\n<li>\u901a\u7528\u5b9a\u65f6\u5668&#xff08;General-purpose TIM&#xff0c;TIM2-TIM5\/TIM9-TIM14&#xff09; \u652f\u6301\u8f93\u5165\u6355\u83b7\u3001\u8f93\u51fa\u6bd4\u8f83\u3001\u7f16\u7801\u5668\u63a5\u53e3\u7b49\u529f\u80fd&#xff0c;\u9002\u7528\u4e8e\u901a\u7528\u5b9a\u65f6\u4efb\u52a1\u3002<\/li>\n<li>\u57fa\u672c\u5b9a\u65f6\u5668&#xff08;Basic TIM&#xff0c;TIM6\/TIM7&#xff09; \u4ec5\u652f\u6301\u57fa\u672c\u7684\u8ba1\u65f6\u529f\u80fd&#xff0c;\u5e38\u7528\u4e8e DAC \u89e6\u53d1\u6216\u4f5c\u4e3a\u7b80\u5355\u7684\u65f6\u95f4\u57fa\u51c6\u3002<\/li>\n<li>\u4f4e\u529f\u8017\u5b9a\u65f6\u5668&#xff08;LPTIM&#xff09; \u9002\u7528\u4e8e\u4f4e\u529f\u8017\u5e94\u7528&#xff0c;\u652f\u6301\u8d85\u4f4e\u529f\u8017\u6a21\u5f0f\u4e0b\u7684\u5b9a\u65f6\u529f\u80fd\u3002<\/li>\n<\/ul>\n<p>\u5176\u4e2d&#xff0c;\u9ad8\u7ea7\u5b9a\u65f6\u5668\u6302\u8f7d\u5728APB2&#xff0c;\u901a\u7528\u548c\u57fa\u672c\u5b9a\u65f6\u5668\u6302\u8f7d\u5728APB1\u3002<\/p>\n<h3>2. TIM \u4e3b\u8981\u529f\u80fd<\/h3>\n<p>(1) \u5b9a\u65f6\u4e2d\u65ad<\/p>\n<ul>\n<li>\u53ef\u914d\u7f6e\u5b9a\u65f6\u5668\u5728\u8bbe\u5b9a\u65f6\u95f4\u540e\u89e6\u53d1\u4e2d\u65ad&#xff0c;\u5b9e\u73b0\u5468\u671f\u6027\u4efb\u52a1&#xff0c;\u5982\u7cfb\u7edf\u5fc3\u8df3\u6216 LED \u95ea\u70c1\u3002<\/li>\n<\/ul>\n<p>(2) PWM&#xff08;\u8109\u5bbd\u8c03\u5236&#xff09;<\/p>\n<ul>\n<li>\u901a\u8fc7\u8bbe\u7f6e\u5360\u7a7a\u6bd4&#xff0c;\u63a7\u5236\u8f93\u51fa\u6ce2\u5f62&#xff0c;\u7528\u4e8e\u7535\u673a\u63a7\u5236\u3001LED \u4eae\u5ea6\u8c03\u8282\u7b49\u3002<\/li>\n<\/ul>\n<p>(3) \u8f93\u5165\u6355\u83b7<\/p>\n<ul>\n<li>\u8bb0\u5f55\u5916\u90e8\u4fe1\u53f7\u7684\u5230\u8fbe\u65f6\u95f4&#xff0c;\u4f8b\u5982\u6d4b\u91cf\u4fe1\u53f7\u9891\u7387\u6216\u8109\u51b2\u5bbd\u5ea6\u3002<\/li>\n<\/ul>\n<p>(4) \u8f93\u51fa\u6bd4\u8f83<\/p>\n<ul>\n<li>\u5728\u7279\u5b9a\u65f6\u95f4\u70b9\u6539\u53d8\u8f93\u51fa\u72b6\u6001&#xff0c;\u5b9e\u73b0\u7cbe\u786e\u7684\u4e8b\u4ef6\u89e6\u53d1\u6216\u6ce2\u5f62\u751f\u6210\u3002<\/li>\n<\/ul>\n<p>(5) \u7f16\u7801\u5668\u63a5\u53e3<\/p>\n<ul>\n<li>\u8bfb\u53d6\u589e\u91cf\u5f0f\u7f16\u7801\u5668\u7684\u8109\u51b2\u4fe1\u53f7&#xff0c;\u8fdb\u884c\u4f4d\u79fb\u6216\u89d2\u5ea6\u6d4b\u91cf&#xff0c;\u5e7f\u6cdb\u7528\u4e8e\u8fd0\u52a8\u63a7\u5236\u3002<\/li>\n<\/ul>\n<h3>3. \u57fa\u672cTIM\u4e3b\u4ece\u89e6\u53d1\u6a21\u5f0f<\/h3>\n<p>STM32 \u7684 TIM \u5b9a\u65f6\u5668\u652f\u6301 \u4e3b\u4ece\u6a21\u5f0f&#xff08;Master-Slave Mode&#xff09;&#xff0c;\u662f\u4e00\u79cd\u9ad8\u7ea7\u529f\u80fd&#xff0c;\u5141\u8bb8\u4e00\u4e2a\u5b9a\u65f6\u5668(\u4e3b)\u89e6\u53d1\u53e6\u4e00\u4e2a\u5b9a\u65f6\u5668(\u4ece)\u6216\u5916\u8bbe(\u5982DAC)\u7684\u64cd\u4f5c\u3002<\/p>\n<h3>4. TIM\u901a\u7528\u5b9a\u65f6\u5668<\/h3>\n<p>4.1 \u8ba1\u6570\u6a21\u5f0f&#xff1a; \u5411\u4e0a\u8ba1\u6570 \u5411\u4e0b\u8ba1\u6570 \u4e2d\u592e\u5bf9\u9f50 4.2 \u65f6\u949f\u6e90\u9009\u62e9<\/p>\n<table>\n<tr>\u65f6\u949f\u6e90\u8bf4\u660e\u5178\u578b\u5e94\u7528<\/tr>\n<tbody>\n<tr>\n<td>\u5185\u90e8\u65f6\u949f&#xff08;CK_INT&#xff09;<\/td>\n<td>\u7531 APB1\/APB2 \u603b\u7ebf\u65f6\u949f&#xff08;PCLK&#xff09;\u63d0\u4f9b<\/td>\n<td>\u666e\u901a\u5b9a\u65f6\u3001PWM \u751f\u6210<\/td>\n<\/tr>\n<tr>\n<td>\u5916\u90e8\u65f6\u949f\u6a21\u5f0f1&#xff08;ETR&#xff09;<\/td>\n<td>\u5916\u90e8\u5f15\u811a ETR \u8f93\u5165\u4fe1\u53f7\u4f5c\u4e3a\u65f6\u949f\u6e90<\/td>\n<td>\u9891\u7387\u6d4b\u91cf\u3001\u5916\u90e8\u89e6\u53d1\u63a7\u5236<\/td>\n<\/tr>\n<tr>\n<td>\u5916\u90e8\u65f6\u949f\u6a21\u5f0f2&#xff08;TIx&#xff09;<\/td>\n<td>TI1 \u6216 TI2 \u8f93\u5165\u4fe1\u53f7\u4f5c\u4e3a\u65f6\u949f\u6e90<\/td>\n<td>\u4e8b\u4ef6\u8ba1\u6570&#xff08;\u5982\u7ea2\u5916\u89e3\u7801&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u90e8\u89e6\u53d1&#xff08;ITRx&#xff09;<\/td>\n<td>\u7531\u53e6\u4e00\u4e2a\u5b9a\u65f6\u5668\u7684\u8f93\u51fa\u4f5c\u4e3a\u65f6\u949f<\/td>\n<td>\u591a\u5b9a\u65f6\u5668\u540c\u6b65&#xff08;\u4e3b\u4ece\u6a21\u5f0f&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u7f16\u7801\u5668\u6a21\u5f0f&#xff08;TI1\/TI2&#xff09;<\/td>\n<td>\u4e24\u4e2a\u8f93\u5165\u901a\u9053\u7528\u4e8e\u68c0\u6d4b\u6b63\u4ea4\u7f16\u7801\u5668\u4fe1\u53f7<\/td>\n<td>\u65cb\u8f6c\u7f16\u7801\u5668\u6d4b\u901f\u4e0e\u65b9\u5411\u68c0\u6d4b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>4.3 \u8f93\u51fa\u6bd4\u8f83<\/p>\n<p>\u4f5c\u7528&#xff1a;\u8f93\u51faPWM <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115547-68023dc319d69.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<table>\n<tr>\u6a21\u5f0f\u7f16\u53f7\u8f93\u51fa\u72b6\u6001\u63cf\u8ff0<\/tr>\n<tbody>\n<tr>\n<td>OCM1<\/td>\n<td>Frozen<\/td>\n<td>\u5f53\u8ba1\u6570\u5668\u4e0e\u6bd4\u8f83\u503c\u5339\u914d\u65f6&#xff0c;\u8f93\u51fa\u4fdd\u6301\u5f53\u524d\u72b6\u6001&#xff0c;\u4e0d\u53d1\u751f\u4efb\u4f55\u53d8\u5316\u3002<\/td>\n<\/tr>\n<tr>\n<td>OCM2<\/td>\n<td>Active Level<\/td>\n<td>\u5f53\u8ba1\u6570\u5668\u4e0e\u6bd4\u8f83\u503c\u5339\u914d\u65f6&#xff0c;\u8f93\u51fa\u8bbe\u7f6e\u4e3a\u9ad8\u7535\u5e73&#xff08;HIGH&#xff09;\u3002<\/td>\n<\/tr>\n<tr>\n<td>OCM3<\/td>\n<td>Inactive Level<\/td>\n<td>\u5f53\u8ba1\u6570\u5668\u4e0e\u6bd4\u8f83\u503c\u5339\u914d\u65f6&#xff0c;\u8f93\u51fa\u8bbe\u7f6e\u4e3a\u4f4e\u7535\u5e73&#xff08;LOW&#xff09;\u3002<\/td>\n<\/tr>\n<tr>\n<td>OCM4<\/td>\n<td>Toggle<\/td>\n<td>\u5f53\u8ba1\u6570\u5668\u4e0e\u6bd4\u8f83\u503c\u5339\u914d\u65f6&#xff0c;\u8f93\u51fa\u53cd\u8f6c&#xff08;Toggle&#xff09;\u3002<\/td>\n<\/tr>\n<tr>\n<td>OCM5<\/td>\n<td>Set (PWM Mode)<\/td>\n<td>\u5728 PWM \u6a21\u5f0f\u4e0b&#xff0c;\u5f53\u8ba1\u6570\u5668\u4e0e\u6bd4\u8f83\u503c\u5339\u914d\u65f6&#xff0c;\u8f93\u51fa\u8bbe\u7f6e\u4e3a\u9ad8\u7535\u5e73&#xff08;HIGH&#xff09;\u3002<\/td>\n<\/tr>\n<tr>\n<td>OCM6<\/td>\n<td>Reset (PWM Mode)<\/td>\n<td>\u5728 PWM \u6a21\u5f0f\u4e0b&#xff0c;\u5f53\u8ba1\u6570\u5668\u4e0e\u6bd4\u8f83\u503c\u5339\u914d\u65f6&#xff0c;\u8f93\u51fa\u8bbe\u7f6e\u4e3a\u4f4e\u7535\u5e73&#xff08;LOW&#xff09;\u3002<\/td>\n<\/tr>\n<tr>\n<td>OCM7<\/td>\n<td>PWM Mode (Center-Aligned)<\/td>\n<td>\u5728\u4e2d\u5fc3\u5bf9\u9f50\u6a21\u5f0f\u4e0b&#xff0c;\u8f93\u51fa\u5728\u8ba1\u6570\u5668\u8fbe\u5230\u6bd4\u8f83\u503c\u65f6\u8bbe\u7f6e\u9ad8\u7535\u5e73\u6216\u4f4e\u7535\u5e73\u3002<\/td>\n<\/tr>\n<tr>\n<td>OCM8<\/td>\n<td>PWM Mode (Edge-Aligned)<\/td>\n<td>\u5728\u8fb9\u6cbf\u5bf9\u9f50\u6a21\u5f0f\u4e0b&#xff0c;\u8f93\u51fa\u5728\u8ba1\u6570\u5668\u4e0e\u6bd4\u8f83\u503c\u5339\u914d\u65f6\u4ea7\u751f\u4e00\u4e2a\u8109\u51b2&#xff08;Pulse&#xff09;\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li>Frozen \u6a21\u5f0f&#xff1a;\u4fdd\u6301\u8f93\u51fa\u4e0d\u53d8&#xff0c;\u9002\u7528\u4e8e\u4fdd\u6301\u5b9a\u65f6\u5668\u8f93\u51fa\u7a33\u5b9a\u7684\u60c5\u51b5\u3002<\/li>\n<li>Active Level&#xff1a;\u8f93\u51fa\u8bbe\u4e3a\u9ad8\u7535\u5e73&#xff0c;\u9002\u7528\u4e8e\u9700\u8981\u5e38\u5f00\u8f93\u51fa\u7684\u60c5\u51b5\u3002<\/li>\n<li>Inactive Level&#xff1a;\u8f93\u51fa\u8bbe\u4e3a\u4f4e\u7535\u5e73&#xff0c;\u9002\u7528\u4e8e\u9700\u8981\u5e38\u95ed\u8f93\u51fa\u7684\u60c5\u51b5\u3002<\/li>\n<li>Toggle&#xff1a;\u6bcf\u6b21\u5339\u914d\u90fd\u4f1a\u5207\u6362\u8f93\u51fa\u72b6\u6001&#xff0c;\u9002\u7528\u4e8e\u9700\u8981\u5468\u671f\u6027\u53cd\u8f6c\u8f93\u51fa\u7684\u573a\u666f\u3002<\/li>\n<li>Set \u548c Reset&#xff1a;\u5728 PWM \u6a21\u5f0f\u4e0b\u4f7f\u7528&#xff0c;\u7528\u4e8e\u63a7\u5236\u8f93\u51fa\u6ce2\u5f62\u7684\u9ad8\u4f4e\u7535\u5e73\u3002<\/li>\n<li>PWM Mode (Center-Aligned) \u548c PWM Mode (Edge-Aligned)&#xff1a;\u9002\u7528\u4e8e\u63a7\u5236\u5360\u7a7a\u6bd4\u7684\u8109\u51b2\u5bbd\u5ea6\u8c03\u5236&#xff0c;\u5206\u522b\u9002\u7528\u4e8e\u4e2d\u5fc3\u5bf9\u9f50\u548c\u8fb9\u6cbf\u5bf9\u9f50\u6a21\u5f0f\u3002<\/li>\n<\/ul>\n<p>4.4 \u8f93\u5165\u6355\u83b7<\/p>\n<h3>5. TIM\u9ad8\u7ea7\u5b9a\u65f6\u5668<\/h3>\n<p>5.1 \u91cd\u590d\u6b21\u6570\u8ba1\u6570\u5668 \u91cd\u590d\u591a\u6b21\u624d\u4f1a\u89e6\u53d1\u4e2d\u65ad 5.2 \u8f93\u51fa\u6bd4\u8f83\u6a21\u5757\u7684\u5347\u7ea7 \u4ee5\u4e0b\u529f\u80fd\u4e3b\u8981\u7528\u4e8e\u7535\u673a\u63a7\u5236<\/p>\n<ul>\n<li>\u4e92\u8865pwm<\/li>\n<li>\u6b7b\u533a\u751f\u6210\u7535\u8def<\/li>\n<li>\u5239\u8f66\u8f93\u5165<\/li>\n<\/ul>\n<h3>6. \u5b9a\u65f6\u5668\u914d\u7f6e\u6d41\u7a0b<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115547-68023dc36fc9b.png\" alt=\"\u6c5f\u79d1\u5927\u7684\u56fe\" \/> \u4f9d\u6b21\u914d\u7f6e<\/p>\n<li>RCC\u5f00\u542f<\/li>\n<li>\u9009\u62e9\u65f6\u57fa\u5355\u5143\u7684\u65f6\u949f\u6e90<\/li>\n<li>\u914d\u7f6e\u8f93\u51fa\u4e2d\u65ad\u63a7\u5236<\/li>\n<li>\u914d\u7f6eNVIC&#xff0c;\u914d\u7f6e\u4f18\u5148\u7ea7&#xff0c;\u5f00\u542f\u901a\u9053<\/li>\n<li>\u4f7f\u80fd\u8ba1\u6570\u5668<\/li>\n<li>\u4e66\u5199\u4e2d\u65ad\u51fd\u6570<\/li>\n<p>6.1 \u914d\u7f6e\u51fd\u6570<\/p>\n<p><span class=\"token comment\">\/*<br \/>\n\u529f\u80fd&#xff1a;\u6b64\u51fd\u6570\u7528\u4e8e\u5c06\u6307\u5b9a\u7684\u5b9a\u65f6\u5668 (TIMx) \u8fdb\u884c\u786c\u4ef6\u590d\u4f4d&#xff0c;\u5c06\u5176\u914d\u7f6e\u6062\u590d\u4e3a\u9ed8\u8ba4\u72b6\u6001\u3002<\/p>\n<p>\u53c2\u6570&#xff1a;TIMx&#xff1a;\u6307\u5411\u76ee\u6807\u5b9a\u65f6\u5668\u7684\u6307\u9488&#xff0c;\u4f8b\u5982 TIM1, TIM2, \u7b49\u3002<br \/>\n*\/<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">TIM_DeInit<\/span><span class=\"token punctuation\">(<\/span>TIM_TypeDef<span class=\"token operator\">*<\/span> TIMx<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/*<br \/>\n\u529f\u80fd&#xff1a;\u521d\u59cb\u5316\u5b9a\u65f6\u5668\u7684\u57fa\u672c\u65f6\u95f4\u914d\u7f6e&#xff0c;\u5305\u62ec\u8ba1\u6570\u5668\u7684\u9884\u5206\u9891\u5668\u3001\u8ba1\u6570\u5668\u7684\u81ea\u52a8\u91cd\u8f7d\u503c\u3001\u8ba1\u6570\u6a21\u5f0f\u7b49\u3002<\/p>\n<p>\u53c2\u6570&#xff1a;<\/p>\n<p>TIMx&#xff1a;\u6307\u5411\u76ee\u6807\u5b9a\u65f6\u5668\u7684\u6307\u9488\u3002<\/p>\n<p>TIM_TimeBaseInitStruct&#xff1a;\u4e00\u4e2a\u6307\u5411 TIM_TimeBaseInitTypeDef \u7ed3\u6784\u4f53\u7684\u6307\u9488&#xff0c;\u5305\u542b\u521d\u59cb\u5316\u6240\u9700\u7684\u65f6\u95f4\u57fa\u672c\u914d\u7f6e\u53c2\u6570\u3002<br \/>\n*\/<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">TIM_TimeBaseInit<\/span><span class=\"token punctuation\">(<\/span>TIM_TypeDef<span class=\"token operator\">*<\/span> TIMx<span class=\"token punctuation\">,<\/span> TIM_TimeBaseInitTypeDef<span class=\"token operator\">*<\/span> TIM_TimeBaseInitStruct<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/*<br \/>\n\u529f\u80fd&#xff1a;\u5c06 TIM_TimeBaseInitTypeDef \u7ed3\u6784\u4f53\u521d\u59cb\u5316\u4e3a\u9ed8\u8ba4\u503c\u3002\u901a\u5e38\u5728\u8bbe\u7f6e\u5b9a\u65f6\u5668\u65f6&#xff0c;\u5148\u8c03\u7528\u6b64\u51fd\u6570\u6e05\u9664\u7ed3\u6784\u4f53\u4e2d\u7684\u65e7\u914d\u7f6e&#xff0c;\u7136\u540e\u518d\u914d\u7f6e\u65b0\u7684\u53c2\u6570\u3002<\/p>\n<p>\u53c2\u6570&#xff1a;TIM_TimeBaseInitStruct&#xff1a;\u6307\u5411 TIM_TimeBaseInitTypeDef \u7ed3\u6784\u4f53\u7684\u6307\u9488&#xff0c;\u7528\u4e8e\u4fdd\u5b58\u5b9a\u65f6\u5668\u7684\u65f6\u95f4\u57fa\u672c\u914d\u7f6e\u3002<br \/>\n*\/<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">TIM_TimeBaseStructInit<\/span><span class=\"token punctuation\">(<\/span>TIM_TimeBaseInitTypeDef<span class=\"token operator\">*<\/span> TIM_TimeBaseInitStruct<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/*<br \/>\n\u529f\u80fd&#xff1a;\u542f\u7528\u6216\u7981\u7528\u5b9a\u65f6\u5668\u3002\u4f7f\u80fd\u5b9a\u65f6\u5668\u540e&#xff0c;\u8ba1\u6570\u5668\u5f00\u59cb\u8ba1\u6570&#xff1b;\u7981\u7528\u5b9a\u65f6\u5668\u5219\u505c\u6b62\u8ba1\u6570\u3002<\/p>\n<p>\u53c2\u6570&#xff1a;<\/p>\n<p>TIMx&#xff1a;\u6307\u5411\u76ee\u6807\u5b9a\u65f6\u5668\u7684\u6307\u9488\u3002<\/p>\n<p>NewState&#xff1a;\u65b0\u72b6\u6001&#xff0c;ENABLE \u542f\u7528\u5b9a\u65f6\u5668&#xff0c;DISABLE \u7981\u7528\u5b9a\u65f6\u5668\u3002<\/p>\n<p>*\/<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">TIM_Cmd<\/span><span class=\"token punctuation\">(<\/span>TIM_TypeDef<span class=\"token operator\">*<\/span> TIMx<span class=\"token punctuation\">,<\/span> FunctionalState NewState<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/*<br \/>\n\u529f\u80fd&#xff1a;\u542f\u7528\u6216\u7981\u7528\u5b9a\u65f6\u5668\u7684\u4e2d\u65ad\u3002\u6839\u636e\u4f20\u5165\u7684\u4e2d\u65ad\u6e90&#xff0c;\u53ef\u4ee5\u542f\u7528\u6216\u7981\u7528\u76f8\u5e94\u7684\u4e2d\u65ad\u3002<\/p>\n<p>\u53c2\u6570&#xff1a;<\/p>\n<p>TIMx&#xff1a;\u6307\u5411\u76ee\u6807\u5b9a\u65f6\u5668\u7684\u6307\u9488\u3002<\/p>\n<p>TIM_IT&#xff1a;\u6307\u5b9a\u5b9a\u65f6\u5668\u4e2d\u65ad\u7c7b\u578b&#xff0c;\u4f8b\u5982 TIM_IT_Update\u3002<\/p>\n<p>NewState&#xff1a;\u65b0\u72b6\u6001&#xff0c;ENABLE \u542f\u7528\u4e2d\u65ad&#xff0c;DISABLE \u7981\u7528\u4e2d\u65ad\u3002<br \/>\n*\/<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">TIM_ITConfig<\/span><span class=\"token punctuation\">(<\/span>TIM_TypeDef<span class=\"token operator\">*<\/span> TIMx<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint16_t<\/span> TIM_IT<span class=\"token punctuation\">,<\/span> FunctionalState NewState<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/\u65f6\u57fa\u9009\u62e9<\/span><br \/>\n<span class=\"token comment\">\/*<br \/>\n\u529f\u80fd&#xff1a;\u9009\u62e9\u5b9a\u65f6\u5668\u7684\u5185\u90e8\u65f6\u949f\u6e90\u8fdb\u884c\u8ba1\u65f6\u3002<\/p>\n<p>\u53c2\u6570&#xff1a;TIMx&#xff1a;\u6307\u5411\u76ee\u6807\u5b9a\u65f6\u5668\u7684\u6307\u9488\u3002<br \/>\n*\/<\/span><\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">TIM_InternalClockConfig<\/span><span class=\"token punctuation\">(<\/span>TIM_TypeDef<span class=\"token operator\">*<\/span> TIMx<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/*<br \/>\n\u529f\u80fd&#xff1a;\u914d\u7f6e\u5b9a\u65f6\u5668\u7684\u5916\u90e8\u8f93\u5165\u89e6\u53d1\u6e90&#xff0c;\u4ee5\u5916\u90e8\u4e8b\u4ef6\u4f5c\u4e3a\u5b9a\u65f6\u5668\u7684\u65f6\u949f\u8f93\u5165\u3002<\/p>\n<p>\u53c2\u6570&#xff1a;<\/p>\n<p>TIMx&#xff1a;\u6307\u5411\u76ee\u6807\u5b9a\u65f6\u5668\u7684\u6307\u9488\u3002<\/p>\n<p>TIM_InputTriggerSource&#xff1a;\u5916\u90e8\u89e6\u53d1\u6e90\u7684\u914d\u7f6e\u3002<br \/>\n*\/<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">TIM_ITRxExternalClockConfig<\/span><span class=\"token punctuation\">(<\/span>TIM_TypeDef<span class=\"token operator\">*<\/span> TIMx<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint16_t<\/span> TIM_InputTriggerSource<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/*<br \/>\n\u529f\u80fd&#xff1a;\u914d\u7f6e\u5b9a\u65f6\u5668\u7684\u8f93\u5165\u6355\u83b7 (Input Capture) \u5916\u90e8\u65f6\u949f\u6e90&#xff0c;\u5305\u62ec\u65f6\u949f\u6e90\u3001\u6781\u6027\u548c\u6ee4\u6ce2\u5668\u914d\u7f6e\u3002<\/p>\n<p>\u53c2\u6570&#xff1a;<\/p>\n<p>TIMx&#xff1a;\u6307\u5411\u76ee\u6807\u5b9a\u65f6\u5668\u7684\u6307\u9488\u3002<\/p>\n<p>TIM_TIxExternalCLKSource&#xff1a;\u5916\u90e8\u65f6\u949f\u6e90\u7684\u914d\u7f6e\u3002<\/p>\n<p>TIM_ICPolarity&#xff1a;\u8f93\u5165\u6355\u83b7\u6781\u6027\u914d\u7f6e&#xff08;\u4e0a\u5347\u6cbf\u6216\u4e0b\u964d\u6cbf\u89e6\u53d1&#xff09;\u3002<\/p>\n<p>ICFilter&#xff1a;\u8f93\u5165\u6355\u83b7\u4fe1\u53f7\u7684\u6ee4\u6ce2\u5668\u914d\u7f6e\u3002<br \/>\n*\/<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">TIM_TIxExternalClockConfig<\/span><span class=\"token punctuation\">(<\/span>TIM_TypeDef<span class=\"token operator\">*<\/span> TIMx<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint16_t<\/span> TIM_TIxExternalCLKSource<span class=\"token punctuation\">,<\/span><br \/>\n                                <span class=\"token class-name\">uint16_t<\/span> TIM_ICPolarity<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint16_t<\/span> ICFilter<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/*<br \/>\n\u529f\u80fd&#xff1a;\u914d\u7f6e\u5b9a\u65f6\u5668\u7684\u5916\u90e8\u89e6\u53d1\u6a21\u5f0f 1&#xff0c;\u7528\u4e8e\u5916\u90e8\u65f6\u949f\u6e90\u7684\u914d\u7f6e\u3002<\/p>\n<p>\u53c2\u6570&#xff1a;<\/p>\n<p>TIMx&#xff1a;\u6307\u5411\u76ee\u6807\u5b9a\u65f6\u5668\u7684\u6307\u9488\u3002<\/p>\n<p>TIM_ExtTRGPrescaler&#xff1a;\u5916\u90e8\u89e6\u53d1\u5668\u9884\u5206\u9891\u5668\u914d\u7f6e\u3002<\/p>\n<p>TIM_ExtTRGPolarity&#xff1a;\u5916\u90e8\u89e6\u53d1\u5668\u6781\u6027\u914d\u7f6e\u3002<\/p>\n<p>ExtTRGFilter&#xff1a;\u5916\u90e8\u89e6\u53d1\u4fe1\u53f7\u7684\u6ee4\u6ce2\u5668\u914d\u7f6e\u3002<br \/>\n*\/<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">TIM_ETRClockMode1Config<\/span><span class=\"token punctuation\">(<\/span>TIM_TypeDef<span class=\"token operator\">*<\/span> TIMx<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint16_t<\/span> TIM_ExtTRGPrescaler<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint16_t<\/span> TIM_ExtTRGPolarity<span class=\"token punctuation\">,<\/span><br \/>\n                             <span class=\"token class-name\">uint16_t<\/span> ExtTRGFilter<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/*<br \/>\n\u529f\u80fd&#xff1a;\u914d\u7f6e\u5b9a\u65f6\u5668\u7684\u5916\u90e8\u89e6\u53d1\u6a21\u5f0f 2&#xff0c;\u7528\u4e8e\u5916\u90e8\u65f6\u949f\u6e90\u7684\u914d\u7f6e\u3002<\/p>\n<p>\u53c2\u6570&#xff1a;<\/p>\n<p>TIMx&#xff1a;\u6307\u5411\u76ee\u6807\u5b9a\u65f6\u5668\u7684\u6307\u9488\u3002<\/p>\n<p>TIM_ExtTRGPrescaler&#xff1a;\u5916\u90e8\u89e6\u53d1\u5668\u9884\u5206\u9891\u5668\u914d\u7f6e\u3002<\/p>\n<p>TIM_ExtTRGPolarity&#xff1a;\u5916\u90e8\u89e6\u53d1\u5668\u6781\u6027\u914d\u7f6e\u3002<\/p>\n<p>ExtTRGFilter&#xff1a;\u5916\u90e8\u89e6\u53d1\u4fe1\u53f7\u7684\u6ee4\u6ce2\u5668\u914d\u7f6e\u3002<br \/>\n*\/<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">TIM_ETRClockMode2Config<\/span><span class=\"token punctuation\">(<\/span>TIM_TypeDef<span class=\"token operator\">*<\/span> TIMx<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint16_t<\/span> TIM_ExtTRGPrescaler<span class=\"token punctuation\">,<\/span><br \/>\n                             <span class=\"token class-name\">uint16_t<\/span> TIM_ExtTRGPolarity<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint16_t<\/span> ExtTRGFilter<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/*<br \/>\n\u529f\u80fd&#xff1a;\u914d\u7f6e\u5b9a\u65f6\u5668\u7684\u5916\u90e8\u89e6\u53d1\u6e90\u914d\u7f6e\u3002<\/p>\n<p>\u53c2\u6570&#xff1a;<\/p>\n<p>TIMx&#xff1a;\u6307\u5411\u76ee\u6807\u5b9a\u65f6\u5668\u7684\u6307\u9488\u3002<\/p>\n<p>TIM_ExtTRGPrescaler&#xff1a;\u5916\u90e8\u89e6\u53d1\u5668\u9884\u5206\u9891\u5668\u914d\u7f6e\u3002<\/p>\n<p>TIM_ExtTRGPolarity&#xff1a;\u5916\u90e8\u89e6\u53d1\u5668\u6781\u6027\u914d\u7f6e\u3002<\/p>\n<p>ExtTRGFilter&#xff1a;\u5916\u90e8\u89e6\u53d1\u4fe1\u53f7\u7684\u6ee4\u6ce2\u5668\u914d\u7f6e\u3002<br \/>\n*\/<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">TIM_ETRConfig<\/span><span class=\"token punctuation\">(<\/span>TIM_TypeDef<span class=\"token operator\">*<\/span> TIMx<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint16_t<\/span> TIM_ExtTRGPrescaler<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint16_t<\/span> TIM_ExtTRGPolarity<span class=\"token punctuation\">,<\/span><br \/>\n                   <span class=\"token class-name\">uint16_t<\/span> ExtTRGFilter<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/*<br \/>\n\u529f\u80fd&#xff1a;\u8bbe\u7f6e\u5b9a\u65f6\u5668\u7684\u9884\u5206\u9891\u5668&#xff0c;\u7528\u4e8e\u8c03\u6574\u5b9a\u65f6\u5668\u7684\u8ba1\u6570\u901f\u5ea6\u3002<\/p>\n<p>\u53c2\u6570&#xff1a;<\/p>\n<p>TIMx&#xff1a;\u6307\u5411\u76ee\u6807\u5b9a\u65f6\u5668\u7684\u6307\u9488\u3002<\/p>\n<p>Prescaler&#xff1a;\u9884\u5206\u9891\u5668\u503c&#xff0c;\u7528\u4e8e\u8c03\u6574\u8ba1\u6570\u9891\u7387\u3002<\/p>\n<p>TIM_PSCReloadMode&#xff1a;\u9884\u5206\u9891\u5668\u91cd\u8f7d\u6a21\u5f0f&#xff0c;\u51b3\u5b9a\u4f55\u65f6\u66f4\u65b0\u9884\u5206\u9891\u5668\u503c&#xff08;TIM_PSCReloadMode_Immediate \u6216 TIM_PSCReloadMode_Update&#xff09;\u3002<br \/>\n*\/<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">TIM_PrescalerConfig<\/span><span class=\"token punctuation\">(<\/span>TIM_TypeDef<span class=\"token operator\">*<\/span> TIMx<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint16_t<\/span> Prescaler<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint16_t<\/span> TIM_PSCReloadMode<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/*<br \/>\n\u529f\u80fd&#xff1a;\u914d\u7f6e\u5b9a\u65f6\u5668\u7684\u8ba1\u6570\u6a21\u5f0f&#xff0c;\u51b3\u5b9a\u8ba1\u6570\u5668\u662f\u5411\u4e0a\u8ba1\u6570\u3001\u5411\u4e0b\u8ba1\u6570\u8fd8\u662f\u53cc\u5411\u8ba1\u6570\u3002<\/p>\n<p>\u53c2\u6570&#xff1a;<\/p>\n<p>TIMx&#xff1a;\u6307\u5411\u76ee\u6807\u5b9a\u65f6\u5668\u7684\u6307\u9488\u3002<\/p>\n<p>TIM_CounterMode&#xff1a;\u8ba1\u6570\u6a21\u5f0f&#xff0c;\u901a\u5e38\u6709 TIM_CounterMode_Up (\u5411\u4e0a\u8ba1\u6570)\u3001TIM_CounterMode_Down (\u5411\u4e0b\u8ba1\u6570) \u548c TIM_CounterMode_CenterAligned (\u4e2d\u5fc3\u5bf9\u9f50\u6a21\u5f0f)\u3002<br \/>\n*\/<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">TIM_CounterModeConfig<\/span><span class=\"token punctuation\">(<\/span>TIM_TypeDef<span class=\"token operator\">*<\/span> TIMx<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint16_t<\/span> TIM_CounterMode<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/*<br \/>\n\u529f\u80fd&#xff1a;\u914d\u7f6e\u5b9a\u65f6\u5668\u7684\u81ea\u52a8\u91cd\u8f7d\u5bc4\u5b58\u5668 (ARR) \u9884\u52a0\u8f7d&#xff0c;\u4f7f\u5f97 ARR \u7684\u66f4\u65b0\u503c\u5728\u4e0b\u4e00\u6b21\u8ba1\u6570\u5468\u671f\u5f00\u59cb\u65f6\u751f\u6548\u3002<\/p>\n<p>\u53c2\u6570&#xff1a;<\/p>\n<p>TIMx&#xff1a;\u6307\u5411\u76ee\u6807\u5b9a\u65f6\u5668\u7684\u6307\u9488\u3002<\/p>\n<p>NewState&#xff1a;\u65b0\u72b6\u6001&#xff0c;ENABLE \u542f\u7528\u9884\u52a0\u8f7d&#xff0c;DISABLE \u7981\u7528\u9884\u52a0\u8f7d\u3002<br \/>\n*\/<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">TIM_ARRPreloadConfig<\/span><span class=\"token punctuation\">(<\/span>TIM_TypeDef<span class=\"token operator\">*<\/span> TIMx<span class=\"token punctuation\">,<\/span> FunctionalState NewState<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/*<br \/>\n\u529f\u80fd&#xff1a;\u8bbe\u7f6e\u5b9a\u65f6\u5668\u8ba1\u6570\u5668\u7684\u5f53\u524d\u503c\u3002<\/p>\n<p>\u53c2\u6570&#xff1a;<\/p>\n<p>TIMx&#xff1a;\u6307\u5411\u76ee\u6807\u5b9a\u65f6\u5668\u7684\u6307\u9488\u3002<\/p>\n<p>Counter&#xff1a;\u8981\u8bbe\u7f6e\u7684\u8ba1\u6570\u5668\u503c\u3002<br \/>\n*\/<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">TIM_SetCounter<\/span><span class=\"token punctuation\">(<\/span>TIM_TypeDef<span class=\"token operator\">*<\/span> TIMx<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint32_t<\/span> Counter<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/*<br \/>\n\u529f\u80fd&#xff1a;\u8bbe\u7f6e\u5b9a\u65f6\u5668\u7684\u81ea\u52a8\u91cd\u8f7d\u503c&#xff0c;\u5b9a\u65f6\u5668\u7684\u8ba1\u6570\u5668\u4f1a\u5728\u8fbe\u5230\u8be5\u503c\u65f6\u81ea\u52a8\u91cd\u65b0\u52a0\u8f7d\u5e76\u6e05\u96f6\u3002<\/p>\n<p>\u53c2\u6570&#xff1a;<\/p>\n<p>TIMx&#xff1a;\u6307\u5411\u76ee\u6807\u5b9a\u65f6\u5668\u7684\u6307\u9488\u3002<\/p>\n<p>Autoreload&#xff1a;\u81ea\u52a8\u91cd\u8f7d\u503c\u3002<br \/>\n*\/<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">TIM_SetAutoreload<\/span><span class=\"token punctuation\">(<\/span>TIM_TypeDef<span class=\"token operator\">*<\/span> TIMx<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint32_t<\/span> Autoreload<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/*<br \/>\n\u529f\u80fd&#xff1a;\u83b7\u53d6\u5b9a\u65f6\u5668\u5f53\u524d\u7684\u8ba1\u6570\u503c\u3002<\/p>\n<p>\u53c2\u6570&#xff1a;<\/p>\n<p>TIMx&#xff1a;\u6307\u5411\u76ee\u6807\u5b9a\u65f6\u5668\u7684\u6307\u9488\u3002<br \/>\n*\/<\/span><br \/>\n<span class=\"token class-name\">uint32_t<\/span> <span class=\"token function\">TIM_GetCounter<\/span><span class=\"token punctuation\">(<\/span>TIM_TypeDef<span class=\"token operator\">*<\/span> TIMx<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/*<br \/>\n\u529f\u80fd&#xff1a;\u83b7\u53d6\u5b9a\u65f6\u5668\u7684\u5f53\u524d\u9884\u5206\u9891\u5668\u503c\u3002<\/p>\n<p>\u53c2\u6570&#xff1a;<\/p>\n<p>TIMx&#xff1a;\u6307\u5411\u76ee\u6807\u5b9a\u65f6\u5668\u7684\u6307\u9488\u3002<br \/>\n*\/<\/span><br \/>\n<span class=\"token class-name\">uint16_t<\/span> <span class=\"token function\">TIM_GetPrescaler<\/span><span class=\"token punctuation\">(<\/span>TIM_TypeDef<span class=\"token operator\">*<\/span> TIMx<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>6.2 \u4e2d\u65ad\u76f8\u5173\u51fd\u6570<\/p>\n<p><span class=\"token comment\">\/*<br \/>\n\u529f\u80fd&#xff1a;\u68c0\u67e5\u6307\u5b9a\u5b9a\u65f6\u5668\u7684\u4e2d\u65ad\u662f\u5426\u88ab\u89e6\u53d1&#xff0c;\u5373\u83b7\u53d6\u6307\u5b9a\u7684\u4e2d\u65ad\u6807\u5fd7\u4f4d\u7684\u72b6\u6001\u3002<\/p>\n<p>\u53c2\u6570&#xff1a;<\/p>\n<p>TIMx&#xff1a;\u6307\u5411\u76ee\u6807\u5b9a\u65f6\u5668\u7684\u6307\u9488&#xff08;\u4f8b\u5982 TIM1, TIM2 \u7b49&#xff09;\u3002<\/p>\n<p>TIM_IT&#xff1a;\u8981\u68c0\u67e5\u7684\u5b9a\u65f6\u5668\u4e2d\u65ad\u7c7b\u578b\u3002\u5e38\u89c1\u7684\u5b9a\u65f6\u5668\u4e2d\u65ad\u7c7b\u578b\u5305\u62ec&#xff1a;<\/p>\n<p>TIM_IT_Update&#xff1a;\u66f4\u65b0\u4e2d\u65ad\u6807\u5fd7&#xff08;\u8ba1\u6570\u5668\u6ea2\u51fa\u6216\u81ea\u52a8\u91cd\u8f7d\u503c\u66f4\u65b0\u65f6\u89e6\u53d1&#xff09;\u3002<\/p>\n<p>TIM_IT_CC1&#xff1a;\u6355\u83b7\u6bd4\u8f83 1 \u4e2d\u65ad\u6807\u5fd7\u3002<\/p>\n<p>TIM_IT_CC2&#xff1a;\u6355\u83b7\u6bd4\u8f83 2 \u4e2d\u65ad\u6807\u5fd7\u3002<\/p>\n<p>TIM_IT_CC3&#xff1a;\u6355\u83b7\u6bd4\u8f83 3 \u4e2d\u65ad\u6807\u5fd7\u3002<\/p>\n<p>TIM_IT_CC4&#xff1a;\u6355\u83b7\u6bd4\u8f83 4 \u4e2d\u65ad\u6807\u5fd7\u3002<\/p>\n<p>\u8fd9\u4e9b\u4e2d\u65ad\u7c7b\u578b\u5e38\u89c1\u4e8e\u5b9a\u65f6\u5668\u7684\u914d\u7f6e\u4e2d&#xff0c;\u5f53\u5b9a\u65f6\u5668\u8fbe\u5230\u7279\u5b9a\u6761\u4ef6\u65f6\u89e6\u53d1\u4e2d\u65ad\u3002<br \/>\n*\/<\/span><br \/>\nITStatus <span class=\"token function\">TIM_GetITStatus<\/span><span class=\"token punctuation\">(<\/span>TIM_TypeDef<span class=\"token operator\">*<\/span> TIMx<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint16_t<\/span> TIM_IT<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/*<br \/>\n\u529f\u80fd&#xff1a;\u6e05\u9664\u6307\u5b9a\u7684\u5b9a\u65f6\u5668\u4e2d\u65ad\u6302\u8d77\u6807\u5fd7\u3002\u5b9a\u65f6\u5668\u4e2d\u65ad\u7684\u6302\u8d77\u6807\u5fd7\u4f4d\u5728\u4e2d\u65ad\u53d1\u751f\u65f6\u4f1a\u88ab\u8bbe\u7f6e&#xff0c;\u8be5\u51fd\u6570\u7528\u4e8e\u624b\u52a8\u6e05\u9664\u8be5\u6807\u5fd7\u4f4d&#xff0c;\u901a\u5e38\u5728\u5904\u7406\u4e2d\u65ad\u540e\u8c03\u7528&#xff0c;\u786e\u4fdd\u4e2d\u65ad\u4e0d\u4f1a\u91cd\u590d\u89e6\u53d1\u3002<\/p>\n<p>\u53c2\u6570&#xff1a;<\/p>\n<p>TIMx&#xff1a;\u6307\u5411\u76ee\u6807\u5b9a\u65f6\u5668\u7684\u6307\u9488&#xff08;\u4f8b\u5982 TIM1, TIM2 \u7b49&#xff09;\u3002<\/p>\n<p>TIM_IT&#xff1a;\u8981\u6e05\u9664\u7684\u5b9a\u65f6\u5668\u4e2d\u65ad\u7c7b\u578b&#xff08;\u4e0e TIM_GetITStatus \u4e2d\u4f7f\u7528\u7684\u7c7b\u578b\u76f8\u540c&#xff09;\u3002<\/p>\n<p>\u4f8b\u5982&#xff0c;TIM_IT_Update\u3001TIM_IT_CC1 \u7b49\u3002<br \/>\n*\/<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">TIM_ClearITPendingBit<\/span><span class=\"token punctuation\">(<\/span>TIM_TypeDef<span class=\"token operator\">*<\/span> TIMx<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint16_t<\/span> TIM_IT<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>6.3 \u5916\u90e8\u65f6\u949f<\/p>\n<h2>\u77e5\u8bc6\u70b9\u56de\u987e<\/h2>\n<p>\u57fa\u7840 STM32\u7684\u5b9a\u65f6\u5668\u4e3b\u8981\u5206\u4e3a\u54ea\u51e0\u7c7b&#xff1f;\u5b83\u4eec\u4e4b\u95f4\u6709\u4ec0\u4e48\u533a\u522b&#xff1f;<\/p>\n<p>\u8bf7\u7b80\u8981\u63cf\u8ff0STM32\u5b9a\u65f6\u5668\u7684\u4e3b\u8981\u529f\u80fd\u6709\u54ea\u4e9b&#xff1f;<\/p>\n<p>\u5b9a\u65f6\u5668\u7684\u65f6\u949f\u6e90\u53ef\u4ee5\u6765\u81ea\u54ea\u91cc&#xff1f;\u5982\u4f55\u914d\u7f6e\u4e0d\u540c\u7684\u65f6\u949f\u6e90&#xff1f; \u901a\u7528TIM \u901a\u7528\u5b9a\u65f6\u5668\u6709\u54ea\u51e0\u79cd\u8ba1\u6570\u6a21\u5f0f&#xff1f;\u8bf7\u5206\u522b\u63cf\u8ff0\u5b83\u4eec\u7684\u7279\u70b9\u3002<\/p>\n<p>\u5982\u4f55\u914d\u7f6e\u5b9a\u65f6\u5668\u7684\u5411\u4e0a\u8ba1\u6570\u6a21\u5f0f&#xff1f;\u8bf7\u63cf\u8ff0\u76f8\u5173\u5bc4\u5b58\u5668\u7684\u8bbe\u7f6e\u3002<\/p>\n<p>\u4ec0\u4e48\u662f\u5b9a\u65f6\u5668\u7684\u9884\u5206\u9891\u5668(Prescaler)\u548c\u81ea\u52a8\u91cd\u88c5\u8f7d\u5bc4\u5b58\u5668(ARR)&#xff1f;\u5b83\u4eec\u7684\u4f5c\u7528\u662f\u4ec0\u4e48&#xff1f;<\/p>\n<p>\u8bf7\u89e3\u91caPWM\u8f93\u51fa\u7684\u539f\u7406&#xff0c;\u5e76\u63cf\u8ff0\u5982\u4f55\u5728STM32\u5b9a\u65f6\u5668\u4e0a\u914d\u7f6ePWM\u8f93\u51fa\u3002<\/p>\n<p>\u4ec0\u4e48\u662f\u8f93\u51fa\u6bd4\u8f83\u529f\u80fd&#xff1f;\u5982\u4f55\u914d\u7f6e\u5b9a\u65f6\u5668\u7684\u8f93\u51fa\u6bd4\u8f83\u6a21\u5f0f&#xff1f; \u4e3b\u4ece\u89e6\u53d1 \u4ec0\u4e48\u662f\u5b9a\u65f6\u5668\u7684\u4e3b\u4ece\u6a21\u5f0f&#xff1f;\u6709\u4ec0\u4e48\u5e94\u7528\u573a\u666f&#xff1f;<\/p>\n<p>\u8bf7\u4e3e\u4f8b\u8bf4\u660e\u5982\u4f55\u914d\u7f6e\u4e00\u4e2a\u5b9a\u65f6\u5668\u4f5c\u4e3a\u4e3b\u8bbe\u5907&#xff0c;\u53e6\u4e00\u4e2a\u4f5c\u4e3a\u4ece\u8bbe\u5907&#xff1f;<\/p>\n<p>\u5b9a\u65f6\u5668\u4e4b\u95f4\u53ef\u4ee5\u901a\u8fc7\u54ea\u4e9b\u4fe1\u53f7\u8fdb\u884c\u540c\u6b65&#xff1f; \u9ad8\u7ea7TIM \u9ad8\u7ea7\u5b9a\u65f6\u5668\u76f8\u6bd4\u901a\u7528\u5b9a\u65f6\u5668\u6709\u54ea\u4e9b\u989d\u5916\u7684\u529f\u80fd&#xff1f;<\/p>\n<p>\u5982\u4f55\u914d\u7f6e\u4e92\u8865PWM\u8f93\u51fa&#xff1f;\u9700\u8981\u8003\u8651\u54ea\u4e9b\u4fdd\u62a4\u673a\u5236&#xff1f;<\/p>\n<p>\u4ec0\u4e48\u662f\u6b7b\u533a\u65f6\u95f4&#xff1f;\u4e3a\u4ec0\u4e48\u5728\u7535\u673a\u63a7\u5236\u4e2d\u9700\u8981\u8bbe\u7f6e\u6b7b\u533a\u65f6\u95f4&#xff1f; \u4e2d\u65ad\u914d\u7f6e \u5b9a\u65f6\u5668\u4e2d\u65ad\u914d\u7f6e\u7684\u57fa\u672c\u6d41\u7a0b\u662f\u4ec0\u4e48&#xff1f;<\/p>\n<p>\u5b9a\u65f6\u5668\u53ef\u4ee5\u4ea7\u751f\u54ea\u4e9b\u7c7b\u578b\u7684\u4e2d\u65ad&#xff1f;\u5982\u4f55\u4f7f\u80fd\u8fd9\u4e9b\u4e2d\u65ad&#xff1f;<\/p>\n<p>\u5728\u4e2d\u65ad\u670d\u52a1\u51fd\u6570\u4e2d&#xff0c;\u5982\u4f55\u5224\u65ad\u662f\u54ea\u4e2a\u5b9a\u65f6\u5668\u4e2d\u65ad\u6e90\u89e6\u53d1\u4e86\u4e2d\u65ad&#xff1f; \u5b9e\u9645\u5e94\u7528 \u5982\u4f55\u4f7f\u7528\u5b9a\u65f6\u5668\u6d4b\u91cf\u5916\u90e8\u8109\u51b2\u7684\u9891\u7387\u548c\u5360\u7a7a\u6bd4&#xff1f;<\/p>\n<p>\u5982\u4f55\u5229\u7528\u5b9a\u65f6\u5668\u5b9e\u73b0\u7cbe\u786e\u7684\u5ef6\u65f6\u529f\u80fd&#xff1f;<\/p>\n<p>\u5728\u4f4e\u529f\u8017\u5e94\u7528\u4e2d&#xff0c;\u5982\u4f55\u914d\u7f6e\u5b9a\u65f6\u5668\u4ee5\u6700\u5c0f\u5316\u529f\u8017&#xff1f;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e7\u6b21\uff0c\u6536\u85cf9\u6b21\u3002\u5176\u4e2d\uff0c\u3002_stm32 tim1 tim8\u4e3b\u4ece\u6a21\u5f0f<\/p>\n","protected":false},"author":2,"featured_media":12836,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[217,270,269],"topic":[],"class_list":["post-12838","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-stm32","tag-270","tag-269"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>STM32\u516b\u80a1\u30105\u3011- TIM\u5b9a\u65f6\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/12838.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"STM32\u516b\u80a1\u30105\u3011- TIM\u5b9a\u65f6\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e7\u6b21\uff0c\u6536\u85cf9\u6b21\u3002\u5176\u4e2d\uff0c\u3002_stm32 tim1 tim8\u4e3b\u4ece\u6a21\u5f0f\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/12838.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T11:55:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115547-68023dc319d69.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/12838.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/12838.html\",\"name\":\"STM32\u516b\u80a1\u30105\u3011- TIM\u5b9a\u65f6\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T11:55:48+00:00\",\"dateModified\":\"2025-04-18T11:55:48+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/12838.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/12838.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/12838.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"STM32\u516b\u80a1\u30105\u3011----- TIM\u5b9a\u65f6\u5668\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"STM32\u516b\u80a1\u30105\u3011- TIM\u5b9a\u65f6\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/12838.html","og_locale":"zh_CN","og_type":"article","og_title":"STM32\u516b\u80a1\u30105\u3011- TIM\u5b9a\u65f6\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e7\u6b21\uff0c\u6536\u85cf9\u6b21\u3002\u5176\u4e2d\uff0c\u3002_stm32 tim1 tim8\u4e3b\u4ece\u6a21\u5f0f","og_url":"https:\/\/www.wsisp.com\/helps\/12838.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T11:55:48+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115547-68023dc319d69.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/12838.html","url":"https:\/\/www.wsisp.com\/helps\/12838.html","name":"STM32\u516b\u80a1\u30105\u3011- TIM\u5b9a\u65f6\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T11:55:48+00:00","dateModified":"2025-04-18T11:55:48+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/12838.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/12838.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/12838.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"STM32\u516b\u80a1\u30105\u3011----- TIM\u5b9a\u65f6\u5668"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/12838","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=12838"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/12838\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/12836"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=12838"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=12838"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=12838"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=12838"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}