{"id":3207,"date":"2021-06-24T13:01:59","date_gmt":"2021-06-24T13:01:59","guid":{"rendered":""},"modified":"2021-06-24T21:02:37","modified_gmt":"2021-06-24T13:02:37","slug":"%e7%94%b5%e6%9c%ba%e6%8e%a7%e5%88%b6%e5%9f%ba%e7%a1%802%e2%80%94%e2%80%94%e5%ae%9a%e6%97%b6%e5%99%a8%e6%8d%95%e8%8e%b7%e5%8d%95%e8%be%93%e5%85%a5%e8%84%89%e5%86%b2%e5%8e%9f%e7%90%86","status":"publish","type":"post","link":"http:\/\/www.szryc.com\/?p=3207","title":{"rendered":"\u7535\u673a\u63a7\u5236\u57fa\u78402\u2014\u2014\u5b9a\u65f6\u5668\u6355\u83b7\u5355\u8f93\u5165\u8109\u51b2\u539f\u7406"},"content":{"rendered":"

\n\t1 \u95ee\u9898\u5f15\u51fa<\/span><\/h1>\n

\n\t\u5728\u5355\u7247\u673a<\/u>\u4e0e\u5d4c\u5165\u5f0f\u5f00\u53d1\u4e2d\uff0c\u67d0\u4e9b\u573a\u666f\u9700\u8981\u6355\u83b7\u4f20\u611f\u5668<\/u>\u7684\u9ad8\u7535\u5e73\uff08\u6216\u4f4e\u7535\u5e73\uff09\u4fe1\u53f7\u7684\u6301\u7eed\u65f6\u95f4\uff0c\u5982\u7ea2\u5916<\/u>\u89e3\u7801\u4fe1\u53f7\u3001\u7f16\u7801\u5668<\/u>\u8f93\u5165\u4fe1\u53f7\u7b49\u3002<\/span><\/p>\n

\n\t <\/div>\n

\n\t\u5982\u4e0b\u56fe\uff0c\u4ee5\u5355\u4e00\u7684\u4e00\u6bb5\u9ad8\u7535\u5e73\u8f93\u5165\u4fe1\u53f7\u4e3a\u4f8b\uff0c\u5982\u4f55\u6d4b\u91cf<\/u>\u8fd9\u6bb5\u9ad8\u7535\u5e73\u7684\u65f6\u95f4\u5462\uff1f<\/span><\/p>\n

\n\t\u4ece\u76f4\u89c2\u4e0a\u7406\u89e3\uff0c\u5c31\u662f\u8981\u4e0d\u65ad\u7684\u68c0\u6d4b\u8fd9\u4e2a\u4fe1\u53f7\uff0c\u5f53\u4fe1\u53f7\u4ece0\u53d8\u52301\u65f6\uff0c\u8bb0\u5f55\u4e00\u4e2a\u65f6\u95f4\uff0c\u518d\u4ece1\u53d8\u52300\u65f6\uff0c\u8bb0\u5f55\u53e6\u4e00\u4e2a\u65f6\u95f4\uff0c\u4e24\u4e2a\u65f6\u95f4\u5dee\u5c31\u662f\u9ad8\u7535\u5e73\u7684\u6301\u7eed\u65f6\u95f4\u4e86\u3002\u90a3\u5177\u4f53\u8981\u600e\u4e48\u7f16\u7a0b\u5462\uff1f\u8fd9\u5c31\u8981\u7528\u5230\u5b9a\u65f6\u5668\u4e86\u3002<\/span><\/p>\n

\n\t\"\"<\/span><\/p>\n

\n\t2 \u5b9a\u65f6\u5668\u7684\u6355\u83b7\u539f\u7406<\/span><\/h1>\n

\n\t\u4e0a\u7bc7\u4ecb\u7ecd\u4e86\u5b9a\u65f6\u5668\u7684\u8f93\u51fa\u529f\u80fd\uff0c\u672c\u7bc7\u662f\u5229\u7528\u5b9a\u65f6\u5668\u7684\u8f93\u5165\u529f\u80fd\uff0c\u6765\u8ba1\u7b97\u8109\u51b2\u65f6\u957f\u3002\u5982\u4e0b\u56fe\uff1a<\/span><\/p>\n

    \n
  • \n

    \n\t\t\t\u5b9a\u65f6\u5668\u7684CNT\u8ba1\u6570\u5668\u5728\u4e0d\u505c\u7684\u8ba1\u6570<\/span><\/p>\n<\/li>\n

  • \n

    \n\t\t\t\u9996\u5148\u914d\u7f6e\u5b9a\u65f6\u5668\u7684\u8f93\u5165\u901a\u9053\u4e3a\u4e0a\u5347\u6cbf\u6355\u83b7\uff0c\u8fd9\u6837\u5f53\u68c0\u6d4b\u5230\u4ece0\u52301\u7684\u8df3\u53d8\u65f6\uff0cCCR1\u5c31\u4f1a\u5148\u4fdd\u5b58\u5f53\u524d\u7684CNT\u503c\uff0c\u540c\u65f6CNT\u4f1a\u6e05\u96f6\u91cd\u65b0\u5f00\u59cb\u8ba1\u6570<\/span><\/p>\n<\/li>\n

  • \n

    \n\t\t\t\u7136\u540e\u5c06\u5b9a\u65f6\u5668\u7684\u8f93\u5165\u901a\u9053\u4e3a\u4e0b\u964d\u6cbf\u6355\u83b7\uff0c\u5f53\u68c0\u6d4b\u4ece1\u52300\u7684\u8df3\u53d8\u65f6\uff0cCCR2\u5c31\u4f1a\u5148\u4fdd\u5b58\u5f53\u524d\u7684CNT\u503c<\/span><\/p>\n<\/li>\n

  • \n

    \n\t\t\t\u5728\u8fd9\u671f\u95f4\uff0cCNT\u7684\u8ba1\u6570\u503c\u53ef\u80fd\u4f1a\u6ea2\u51fa\uff0c\u8fd9\u4e0d\u5f71\u54cd\uff0c\u8bb0\u5f55\u4e0b\u6ea2\u51fa\u7684\u6b21\u6570\uff0c\u5e76\u91cd\u65b0\u5f00\u59cb\u8ba1\u6570\u5373\u53ef<\/span><\/p>\n<\/li>\n

  • \n

    \n\t\t\t\u6700\u7ec8\uff0ct2-t1\u7684\u9ad8\u7535\u5e73\u65f6\u95f4\uff0c\u5c31\u53ef\u4ee5\u901a\u8fc7N\u6b21\u7684\u6ea2\u51fa\u65f6\u95f4\u52a0CCR2\u4fdd\u5b58\u7684\u65f6\u95f4\u6765\u8ba1\u7b97\u83b7\u5f97\u4e86<\/span><\/p>\n<\/li>\n<\/ul>\n

    \n\t\"poYBAGDQvDmAVWWNAAELc5qfGa4389.png\"<\/span><\/p>\n

    \n\t <\/p>\n

    \n\t <\/p>\n

    \n\t3 \u5b9a\u65f6\u5668\u5e38\u7528\u7684\u5bc4\u5b58\u5668<\/u><\/span><\/h1>\n

    \n\t\u4e0a\u7bc7\u4ecb\u7ecd\u4e86\u5b9a\u65f6\u5668\u8f93\u51faPWM\u65f6\u7528\u5230\u7684\u51e0\u4e2a\u5bc4\u5b58\u5668\uff08CR\u3001CCMR\u3001CNT\u3001PSC\u3001ARR\u3001CCR\u7b49\uff09\uff0c\u8fd9\u91cc\u518d\u4ecb\u7ecd\u51e0\u4e2a\u6355\u83b7\u4fe1\u53f7\u65f6\u9700\u8981\u7528\u5230\u7684\u51e0\u4e2a\u5bc4\u5b58\u5668\uff1a<\/span><\/p>\n

    \n\t3.1 \u6355\u83b7\/\u6bd4\u8f83\u6a21\u5f0f\u5bc4\u5b58\u5668CCMR1<\/span><\/h2>\n

    \n\tCCMR\u5bc4\u5b58\u5668\u4e0a\u7bc7\u5df2\u6709\u4ecb\u7ecd\uff0c\u53ea\u662f\u4e0a\u7bc7\u4ec5\u4ecb\u7ecd\u4e86\u8f93\u51fa\u6a21\u5f0f\u4e0b\u7684\u529f\u80fd\uff0c\u672c\u7bc7\u518d\u4ecb\u7ecd\u4e00\u4e0b\u5b83\u5728\u8f93\u5165\u6a21\u5f0f\u4e0b\u7684\u529f\u80fd\uff1a<\/span><\/p>\n

    \n\t\u8fd9\u4e9b\u901a\u9053\u53ef\u7528\u4e8e<\/span>\u8f93\u5165\uff08\u6355\u83b7\u6a21\u5f0f\uff09<\/strong><\/span>\u6216<\/span>\u8f93\u51fa\uff08\u6bd4\u8f83\u6a21\u5f0f\uff09\u6a21\u5f0f<\/strong><\/span>\u3002\u901a\u9053\u65b9\u5411\u901a\u8fc7\u914d\u7f6e\u76f8\u5e94\u7684 CCxS \u4f4d\u8fdb\u884c\u5b9a\u4e49\u3002\u6b64\u5bc4\u5b58\u5668\u7684\u6240\u6709\u5176\u5b83\u4f4d\u5728\u8f93\u5165\u6a21\u5f0f\u548c\u8f93\u51fa\u6a21\u5f0f\u4e0b\u7684\u529f\u80fd\u5747\u4e0d\u540c\u3002\u5bf9\u4e8e\u4efb\u4e00\u7ed9\u5b9a\u4f4d<\/span><\/p>\n

      \n
    • \n

      \n\t\t\tOCxx \u7528\u4e8e\u8bf4\u660e\u901a\u9053\u914d\u7f6e\u4e3a\u8f93\u51fa\u65f6\u8be5\u4f4d\u5bf9\u5e94\u7684\u529f\u80fd<\/span><\/p>\n<\/li>\n

    • \n

      \n\t\t\tICxx \u5219\u7528\u4e8e\u8bf4\u660e\u901a\u9053\u914d\u7f6e\u4e3a\u8f93\u5165\u65f6 \u8be5\u4f4d\u5bf9\u5e94\u7684\u529f\u80fd<\/span><\/p>\n<\/li>\n<\/ul>\n

      \n\t\u56e0\u6b64\uff0c\u5fc5\u987b\u6ce8\u610f\u540c\u4e00\u4e2a\u4f4d\u5728\u8f93\u5165\u9636\u6bb5\u548c\u8f93\u51fa\u9636\u6bb5\u5177\u6709\u4e0d\u540c\u7684\u542b\u4e49\u3002<\/span><\/p>\n

      \n\t\"poYBAGDQvD-Acon1AABGDNkRr5A476.png\"<\/span><\/p>\n

      \n\t\u8fd9\u91cc\u4ec5\u5148\u4ecb\u7ecd<\/span>\u8f93\u5165\u6a21\u5f0f<\/strong><\/span>\u4e0b\u7684\u529f\u80fd\uff1a<\/span><\/p>\n

        \n
      • \n

        \n\t\t\t\u4f4d 15:12 <\/span>IC2F<\/strong><\/span>\uff1a\u8f93\u5165\u6355\u83b7 2 \u6ee4\u6ce2\u5668<\/u> (Input capture 2 filter)<\/span><\/p>\n<\/li>\n

      • \n

        \n\t\t\t\u4f4d 11:10 <\/span>IC2PSC[1:0]<\/strong><\/span>\uff1a\u8f93\u5165\u6355\u83b7 2 \u9884\u5206\u9891\u5668 (Input capture 2 prescaler)<\/span><\/p>\n<\/li>\n

      • \n

        \n\t\t\t\u4f4d 9:8 <\/span>CC2S<\/strong><\/span>\uff1a\u6355\u83b7\/\u6bd4\u8f83 2 \u9009\u62e9 (Capture\/compare 2 selection)<\/span> \u7528\u6cd5\u53c2\u7167\u4e0b\u9762\u7684CC1S\u901a\u90531<\/span><\/p>\n<\/li>\n

      • \n

        \n\t\t\t\u4f4d 7:4 <\/span>IC1F<\/strong><\/span>\uff1a\u8f93\u5165\u6355\u83b7 1 \u6ee4\u6ce2\u5668 (Input capture 1 filter)<\/span><\/p>\n

        \n\t\t\t\u6570\u5b57\u6ee4\u6ce2\u5668\u7531\u4e8b\u4ef6\u8ba1\u6570\u5668\u7ec4\u6210\uff0c\u6bcf N \u4e2a\u4e8b\u4ef6\u624d\u89c6\u4e3a\u4e00\u4e2a\u6709\u6548\u8fb9\u6cbf\uff1a<\/span><\/p>\n

          \n
        • \n

          \n\t\t\t\t\t0000\uff1a\u65e0\u6ee4\u6ce2\u5668<\/span><\/p>\n<\/li>\n

        • \n

          \n\t\t\t\t\t0001~1111\uff1a\u5176\u5b83\u9891\u7387\u7684\u6ee4\u6ce2\u5668<\/span><\/p>\n<\/li>\n<\/ul>\n<\/li>\n

        • \n

          \n\t\t\t\u4f4d 3:2 <\/span>IC1PSC<\/strong><\/span>\uff1a\u8f93\u5165\u6355\u83b7 1 \u9884\u5206\u9891\u5668 (Input capture 1 prescaler)<\/span><\/p>\n

          \n\t\t\t\u6b64\u4f4d\u57df\u5b9a\u4e49 CC1 \u8f93\u5165 (IC1) \u7684\u9884\u5206\u9891\u6bd4\u3002\u53ea\u8981 CC1E=0\uff08TI<\/u>Mx_CCER \u5bc4\u5b58\u5668\uff09\uff0c\u9884\u5206\u9891\u5668\u4fbf\u7acb\u5373\u590d\u4f4d\u3002<\/span><\/p>\n

            \n
          • \n

            \n\t\t\t\t\t00\uff1a\u65e0\u9884\u5206\u9891\u5668\uff0c\u6355\u83b7\u8f93\u5165\u4e0a\u6bcf\u68c0\u6d4b\u5230\u4e00\u4e2a\u8fb9\u6cbf\u4fbf\u6267\u884c\u6355\u83b7<\/span><\/p>\n<\/li>\n

          • \n

            \n\t\t\t\t\t01~11\uff1a\u6bcf\u53d1\u751f 2 \uff084\u30018\uff09\u4e2a\u4e8b\u4ef6\u4fbf\u6267\u884c\u4e00\u6b21\u6355\u83b7<\/span><\/p>\n<\/li>\n<\/ul>\n<\/li>\n

          • \n

            \n\t\t\t\u4f4d 1:0 <\/span>CC1S<\/strong><\/span>\uff1a\u6355\u83b7\/\u6bd4\u8f83 1 \u9009\u62e9 (Capture\/Compare 1 selection)\uff0c\u6b64\u4f4d\u57df\u5b9a\u4e49\u901a\u9053\u65b9\u5411\uff08\u8f93\u5165\/\u8f93\u51fa\uff09\u4ee5\u53ca\u6240\u4f7f\u7528\u7684\u8f93\u5165\u3002<\/span><\/p>\n

              \n
            • \n

              \n\t\t\t\t\t00\uff1aCC1 \u901a\u9053\u914d\u7f6e\u4e3a\u8f93\u51fa<\/span><\/p>\n<\/li>\n

            • \n

              \n\t\t\t\t\t01\uff1aCC1 \u901a\u9053\u914d\u7f6e\u4e3a\u8f93\u5165\uff0cIC1 \u6620\u5c04\u5230 TI1 \u4e0a<\/span><\/p>\n<\/li>\n

            • \n

              \n\t\t\t\t\t10\uff1aCC1 \u901a\u9053\u914d\u7f6e\u4e3a\u8f93\u5165\uff0cIC1 \u6620\u5c04\u5230 TI2 \u4e0a<\/span><\/p>\n<\/li>\n

            • \n

              \n\t\t\t\t\t11\uff1aCC1 \u901a\u9053\u914d\u7f6e\u4e3a\u8f93\u5165\uff0cIC1 \u6620\u5c04\u5230 TRC \u4e0a\u3002\u6b64\u6a21\u5f0f\u4ec5\u5728\u901a\u8fc7 TS \u4f4d\uff08TIMx_SMCR \u5bc4\u5b58\u5668\uff09\u9009\u62e9\u5185\u90e8\u89e6\u53d1\u8f93\u5165\u65f6\u6709\u6548<\/span><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n

              \n\t\u6ce8\uff1a \u4ec5\u5f53\u901a\u9053\u5173\u95ed\u65f6\uff08TIMx_CCER \u4e2d\u7684 CC1E = 0\uff09\uff0c\u624d\u53ef\u5411 CC1S \u4f4d\u5199\u5165\u6570\u636e\u3002<\/span><\/p>\n

              \n\t3.2 \u6355\u83b7\/\u6bd4\u8f83\u4f7f\u80fd\u5bc4\u5b58\u5668CCER<\/span><\/h2>\n

              \n\t\u6211\u4eec\u8981\u7528\u5230\u8fd9\u4e2a\u5bc4\u5b58\u5668\u7684\u6700\u4f4e 2 \u4f4d\uff0c CC1E \u548c CC1P\u3002<\/span><\/p>\n

              \n\t\"pYYBAGDQvECAG18AAAAqgbJouDE128.png\"<\/span><\/p>\n

                \n
              • \n

                \n\t\t\t\u4f4d 15\u300111\u30017\u30013 <\/span>CCxNP<\/strong><\/span>\uff1a\u6355\u83b7 \/\u6bd4\u8f83x \u8f93\u51fa\u6781\u6027 (Capture\/Comparex output Polarity)\u3002<\/span><\/p>\n

                  \n
                • \n

                  \n\t\t\t\t\tCCx \u901a\u9053\u914d\u7f6e\u4e3a\u8f93\u51fa\uff1a CCxNP \u5fc5\u987b\u4fdd\u6301\u6e05\u96f6\u3002<\/span><\/p>\n<\/li>\n

                • \n

                  \n\t\t\t\t\tCCx \u901a\u9053\u914d\u7f6e\u4e3a\u8f93\u5165\uff1a\u6b64\u4f4d\u4e0e CCxP \u914d\u5408\u4f7f\u7528\uff0c\u7528\u4ee5\u5b9a\u4e49 TI1FP1\/TI2FP1 \u7684\u6781\u6027\u3002\u8bf7\u53c2\u89c1 CCxP \u8bf4\u660e\u3002<\/span><\/p>\n<\/li>\n<\/ul>\n<\/li>\n

                • \n

                  \n\t\t\t\u4f4d 14\u300110\u30016\u30012 \u4fdd\u7559\uff0c\u5fc5\u987b\u4fdd\u6301\u590d\u4f4d\u503c\u3002<\/span><\/p>\n<\/li>\n

                • \n

                  \n\t\t\t\u4f4d 13\u30019\u30015\u30011 <\/span>CCxP<\/strong><\/span>\uff1a\u6355\u83b7 \/\u6bd4\u8f83x \u8f93\u51fa\u6781\u6027 (Capture\/Comparex output Polarity)\u3002<\/span><\/p>\n

                    \n
                  • \n

                    \n\t\t\t\t\t00\uff1a\u975e\u53cd\u76f8\/\u4e0a\u5347\u6cbf\u89e6\u53d1<\/span> \u7535\u8def<\/u>\u5bf9 TIxFP1 \u4e0a\u5347\u6cbf\u654f\u611f \uff08\u5728\u590d\u4f4d\u6a21\u5f0f\u3001\u5916\u90e8\u65f6\u949f<\/u>\u6a21\u5f0f\u6216\u89e6\u53d1\u6a21\u5f0f\u4e0b\u6267\u884c\u6355\u83b7\u6216\u89e6\u53d1\u64cd\u4f5c\uff09\uff0c TIxFP1 \u672a\u53cd\u76f8 \uff08\u5728\u95e8\u63a7\u6a21\u5f0f\u6216\u7f16\u7801\u5668\u6a21\u5f0f\u4e0b\u6267\u884c\u89e6\u53d1\u64cd\u4f5c\uff09\u3002<\/span><\/p>\n<\/li>\n

                  • \n

                    \n\t\t\t\t\t01\uff1a\u53cd\u76f8\/\u4e0b\u964d\u6cbf\u89e6\u53d1<\/span> \u7535\u8def\u5bf9 TIxFP1 \u4e0b\u964d\u6cbf\u654f\u611f \uff08\u5728\u590d\u4f4d\u6a21\u5f0f\u3001\u5916\u90e8\u65f6\u949f\u6a21\u5f0f\u6216\u89e6\u53d1\u6a21\u5f0f\u4e0b\u6267\u884c\u6355\u83b7\u6216\u89e6\u53d1\u64cd\u4f5c\uff09\uff0c TIxFP1 \u53cd\u76f8 \uff08\u5728\u95e8\u63a7\u6a21\u5f0f\u6216\u7f16\u7801\u5668\u6a21\u5f0f\u4e0b\u6267\u884c\u89e6\u53d1\u64cd\u4f5c\uff09\u3002<\/span><\/p>\n<\/li>\n

                  • \n

                    \n\t\t\t\t\t10\uff1a\u4fdd\u7559\uff0c\u4e0d\u4f7f\u7528\u6b64\u914d\u7f6e\u3002<\/span><\/p>\n<\/li>\n

                  • \n

                    \n\t\t\t\t\t11\uff1a\u975e\u53cd\u76f8\/\u4e0a\u5347\u6cbf\u548c\u4e0b\u964d\u6cbf\u5747\u89e6\u53d1<\/span> \u7535\u8def\u5bf9 TIxFP1 \u4e0a\u5347\u6cbf\u548c\u4e0b\u964d\u6cbf\u90fd\u654f\u611f\uff08\u5728\u590d\u4f4d\u6a21\u5f0f\u3001\u5916\u90e8\u65f6\u949f\u6a21\u5f0f\u6216\u89e6\u53d1\u6a21\u5f0f\u4e0b\u6267\u884c\u6355\u83b7\u6216\u89e6\u53d1\u64cd\u4f5c\uff09\uff0cTIxFP1 \u672a\u53cd\u76f8\uff08\u5728\u95e8\u63a7\u6a21\u5f0f\u4e0b\u6267\u884c\u89e6\u53d1\u64cd\u4f5c\uff09\u3002\u7f16\u7801\u5668\u6a21\u5f0f\u4e0b\u4e0d\u5f97\u4f7f\u7528\u6b64\u914d\u7f6e\u3002<\/span><\/p>\n<\/li>\n

                  • \n

                    \n\t\t\t\t\t0\uff1aOCx \u9ad8\u7535\u5e73\u6709\u6548<\/span><\/p>\n<\/li>\n

                  • \n

                    \n\t\t\t\t\t1\uff1aOCx\u4f4e\u7535\u5e73\u6709\u6548<\/span><\/p>\n<\/li>\n

                  • \n

                    \n\t\t\t\t\tCCx \u901a\u9053\u914d\u7f6e\u4e3a<\/span>\u8f93\u51fa<\/strong><\/span>\uff1a<\/span><\/p>\n<\/li>\n

                  • \n

                    \n\t\t\t\t\tCCx \u901a\u9053\u914d\u7f6e\u4e3a<\/span>\u8f93\u5165<\/strong><\/span>\uff1a<\/span><\/p>\n

                    \n\t\t\t\t\tCCxNP\/CCxP \u4f4d\u53ef\u9488\u5bf9\u89e6\u53d1\u6216\u6355\u83b7\u64cd\u4f5c\u9009\u62e9 TI1FP1 \u548c TI2FP1 \u7684\u6781\u6027\u3002<\/span><\/p>\n<\/li>\n<\/ul>\n<\/li>\n

                  • \n

                    \n\t\t\t\u4f4d 12\u30018\u30014\u30010 <\/span>CCxE<\/strong><\/span>\uff1a\u6355\u83b7 \/\u6bd4\u8f83 x \u8f93\u51fa\u4f7f\u80fd (Capture\/Comparex output enable)\u3002<\/span><\/p>\n

                      \n
                    • \n

                      \n\t\t\t\t\t0\uff1a\u7981\u6b62\u6355\u83b7<\/span><\/p>\n<\/li>\n

                    • \n

                      \n\t\t\t\t\t1\uff1a\u4f7f\u80fd\u6355\u83b7<\/span><\/p>\n<\/li>\n

                    • \n

                      \n\t\t\t\t\t0\uff1a\u5173\u95ed––OCx \u672a\u6fc0\u6d3b<\/span><\/p>\n<\/li>\n

                    • \n

                      \n\t\t\t\t\t1\uff1a\u5f00\u542f––\u5728\u76f8\u5e94\u8f93\u51fa\u5f15\u811a\u4e0a\u8f93\u51fa OCx\u4fe1\u53f7<\/span><\/p>\n<\/li>\n

                    • \n

                      \n\t\t\t\t\tCCx \u901a\u9053\u914d\u7f6e\u4e3a<\/span>\u8f93\u51fa<\/strong><\/span>\uff1a<\/span><\/p>\n<\/li>\n

                    • \n

                      \n\t\t\t\t\tCCx \u901a\u9053\u914d\u7f6e\u4e3a<\/span>\u8f93\u5165<\/strong><\/span>\uff1a<\/span><\/p>\n

                      \n\t\t\t\t\t\u6b64\u4f4d\u51b3\u5b9a\u4e86\u662f\u5426\u53ef\u4ee5\u5b9e\u9645\u5c06\u8ba1\u6570\u5668\u503c\u6355\u83b7\u5230\u8f93\u5165\u6355\u83b7\/\u6bd4\u8f83\u5bc4\u5b58\u5668 1 (TIMx_CCR1) \u4e2d\u3002<\/span><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n

                      \n\t3.3 DMA<\/u>\/\u4e2d\u65ad\u4f7f\u80fd\u5bc4\u5b58\u5668DIER<\/span><\/h2>\n

                      \n\t\u6211\u4eec\u9700\u8981\u7528\u5230\u4e2d\u65ad\u6765\u5904\u7406\u6355\u83b7\u6570\u636e\uff0c\u6240\u4ee5\u5fc5\u987b\u5f00\u542f\u901a\u9053 1 \u7684\u6355\u83b7\u6bd4\u8f83\u4e2d\u65ad\uff0c\u5373 <\/span>CC1IE <\/strong><\/span>\u8bbe\u7f6e\u4e3a 1 \u3002<\/span><\/p>\n

                      \n\t\"pYYBAGDQvEGAZLeLAAAkg5HrLUE613.png\"<\/span><\/p>\n

                        \n
                      • \n

                        \n\t\t\t\u4f4d 15\u300113\u30017\u30015 \u4fdd\u7559\uff0c\u5fc5\u987b\u4fdd\u6301\u590d\u4f4d\u503c\u3002<\/span><\/p>\n<\/li>\n

                      • \n

                        \n\t\t\t\u4f4d 14 <\/span>TDE<\/strong><\/span>\uff1a\u89e6\u53d1 DMA \u8bf7\u6c42\u4f7f\u80fd (Trigger DMA request enable)<\/span><\/p>\n<\/li>\n

                      • \n

                        \n\t\t\t\u4f4d 12~\u4f4d9 <\/span>CCxDE<\/strong><\/span>\uff1a\u6355\u83b7\/\u6bd4\u8f83x DMA \u8bf7\u6c42\u4f7f\u80fd (Capture\/Compare 1 DMA request enable)<\/span><\/p>\n<\/li>\n

                      • \n

                        \n\t\t\t\u4f4d 8 <\/span>UDE<\/strong><\/span>\uff1a\u66f4\u65b0 DMA \u8bf7\u6c42\u4f7f\u80fd (Update<\/u> DMA request enable)<\/span><\/p>\n<\/li>\n

                      • \n

                        \n\t\t\t\u4f4d 6 <\/span>TIE<\/strong><\/span>\uff1a\u89e6\u53d1\u4fe1\u53f7(TRGI)\u4e2d\u65ad\u4f7f\u80fd (Trigger interrupt enable)<\/span><\/p>\n<\/li>\n

                      • \n

                        \n\t\t\t\u4f4d 4~\u4f4d1 <\/span>CCxIE<\/strong><\/span>\uff1a\u6355\u83b7\/\u6bd4\u8f83x \u4e2d\u65ad\u4f7f\u80fd (Capture\/Compare 1 interrupt enable)<\/span><\/p>\n<\/li>\n

                      • \n

                        \n\t\t\t\u4f4d 0 <\/span>UIE<\/strong><\/span>\uff1a\u66f4\u65b0\u4e2d\u65ad\u4f7f\u80fd (Update interrupt enable)<\/span><\/p>\n<\/li>\n<\/ul>\n

                        \n\t <\/p>\n

                        \n\t4 \u7f16\u7a0b<\/span><\/h1>\n

                        \n\t4.1 \u5b9a\u65f6\u5668\u521d\u59cb\u5316<\/span><\/h2>\n

                        \n\t4.1.1 GPIO\u521d\u59cb\u5316<\/span><\/h3>\n

                        \n\t\u8fd9\u91cc\u7528\u5230\u7684\u662f\u5b9a\u65f6\u56685\u7684\u901a\u90531\uff0c\u6839\u636eSTM32<\/u>F407\u7684\u6570\u636e\u624b\u518c“3 Pi<\/u>nouts and pin description”\u4e2d\u7684“Table 9. Alternate function mapping”\u590d\u7528\u5f15\u811a\u8bf4\u660e\u8868\uff0c\u53ef\u4ee5\u770b\u5230\u5b9a\u65f6\u56685\u901a\u90531\u5bf9\u5e94\u7684\u5f15\u811a\u4f4dA0\uff0c\u6240\u4ee5\u4f7f\u7528A0\u4f5c\u4e3a\u4fe1\u53f7\u7684\u8f93\u5165\u5f15\u811a\u3002<\/span>\"poYBAGDQvEKAKgZ3AAD7x9uese0683.png\"<\/span><\/p>\n

                        \n\t\u56e0\u6b64\u7a0b\u5e8f\u4e2d\u5bf9A0\u5f15\u811a\u53ef\u4ee5\u8fd9\u6837\u914d\u7f6e\uff0c\u6ce8\u610f\u4e00\u5b9a\u8981<\/span>\u914d\u7f6e\u5f15\u811a\u7684\u590d\u7528\u529f\u80fd<\/strong><\/span>\uff1a<\/span><\/p>\n

                        \r\nGPIO_InitTypeDef<\/span> GPIO_InitStructure<\/span>;      \/*GPIO \u7ed3\u6784\u4f53*\/<\/span><\/span>\r\nRCC_AHB1PeriphClockCmd<\/span>(RCC_AHB1Periph_GPIOA<\/span>, ENABLE<\/span>); \/\/\u4f7f\u80fdPORTA\u65f6\u949f <\/span><\/span>\r\n\r\n\/*\u8f93\u5165\u4fe1\u53f7\u7684GPIO\u521d\u59cb\u5316*\/<\/span><\/span>\r\nGPIO_InitStructure<\/span>.GPIO_Pin<\/span> =<\/span> GPIO_Pin_0<\/span>;      \/\/GPIOA0<\/span><\/span>\r\nGPIO_InitStructure<\/span>.GPIO_Mode<\/span> =<\/span> GPIO_Mode_AF<\/span>;    \/*\u590d\u7528\u529f\u80fd*\/<\/span><\/span>\r\nGPIO_InitStructure<\/span>.GPIO_Speed<\/span> =<\/span> GPIO_Speed_100MHz<\/span>; \/\/\u901f\u5ea6100MHz<\/span><\/span>\r\nGPIO_InitStructure<\/span>.GPIO_OType<\/span> =<\/span> GPIO_OType_PP<\/span>;   \/\/\u63a8\u633d\u590d\u7528\u8f93\u51fa<\/span><\/span>\r\nGPIO_InitStructure<\/span>.GPIO_PuPd<\/span> =<\/span> GPIO_PuPd_DOWN<\/span>;   \/*\u4e0b\u62c9*\/<\/span><\/span>\r\nGPIO_Init<\/span>(GPIOA<\/span>,&<\/span>GPIO_InitStructure<\/span>);        \/\/\u521d\u59cb\u5316PA0<\/span><\/span>\r\n\r\nGPIO_PinAFConfig<\/span>(GPIOA<\/span>,GPIO_PinSource0<\/span>,GPIO_AF_TIM5<\/span>); \/\/PA0\u590d\u7528\u4f4d\u5b9a\u65f6\u56685<\/span><\/span><\/pre>\n

                        \n\t <\/p>\n

                        \n\t4.1.2 \u65f6\u57fa\u521d\u59cb\u5316<\/span><\/h3>\n

                        \n\t\u4f7f\u7528\u5b9a\u65f6\u5668\uff0c\u65f6\u57fa\u521d\u59cb\u5316\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\uff0c\u5c31\u662f\u8981\u8bbe\u7f6e\u4e00\u4e9b\u8ba1\u6570\u7684\u9891\u7387\u4e0e\u6ea2\u51fa\u503c\uff08\u81ea\u52a8\u91cd\u88c5\u8f7d\u503c\uff09\uff1a<\/span><\/p>\n

                        \r\nTIM_TimeBaseInitTypeDef<\/span> TIM_TimeBaseStructure<\/span>; \/*\u65f6\u57fa \u7ed3\u6784\u4f53*\/<\/span><\/span>\r\n\r\n\/*\u65f6\u57fa\u521d\u59cb\u5316*\/<\/span><\/span>\r\nTIM_TimeBaseStructure<\/span>.TIM_Period<\/span>=<\/span>arr<\/span>;   \/* \u81ea\u52a8\u91cd\u88c5\u8f7d\u503c *\/<\/span><\/span>\r\nTIM_TimeBaseStructure<\/span>.TIM_Prescaler<\/span>=<\/span>psc<\/span>; \/* \u5b9a\u65f6\u5668\u5206\u9891 *\/<\/span><\/span>\r\nTIM_TimeBaseStructure<\/span>.TIM_ClockDivision<\/span>=<\/span>TIM_CKD_DIV1<\/span>;<\/span>\r\nTIM_TimeBaseStructure<\/span>.TIM_CounterMode<\/span>=<\/span>TIM_CounterMode_Up<\/span>; \/\/\u5411\u4e0a\u8ba1\u6570\u6a21\u5f0f<\/span><\/span>\r\nTIM_TimeBaseInit<\/span>(TIM5<\/span>,&<\/span>TIM_TimeBaseStructure<\/span>);<\/span><\/pre>\n

                        \n\t <\/p>\n

                        \n\t4.1.3 \u8f93\u5165\u901a\u9053\u521d\u59cb\u5316<\/span><\/h3>\n

                        \n\t\u5c06\u5b9a\u65f6\u5668\u7684\u901a\u90531\u8bbe\u7f6e\u4e3a\u8f93\u5165\u6355\u83b7\u6a21\u5f0f\uff1a<\/span><\/p>\n

                        \r\nTIM_ICInitTypeDef<\/span> TIM5_ICInitStructure<\/span>;    \/*\u8f93\u5165\u901a\u9053 \u7ed3\u6784\u4f53*\/<\/span><\/span>\r\n\r\n\/*\u8f93\u5165\u901a\u9053\u521d\u59cb\u5316\uff0c\u521d\u59cb\u5316TIM5\u8f93\u5165\u6355\u83b7\u53c2\u6570*\/<\/span><\/span>\r\nTIM5_ICInitStructure<\/span>.TIM_Channel<\/span> =<\/span> TIM_Channel_1<\/span>;        \/\/CC1S=01 \u9009\u62e9\u8f93\u5165\u7aef IC1\u6620\u5c04\u5230TI1\u4e0a<\/span><\/span>\r\nTIM5_ICInitStructure<\/span>.TIM_ICPolarity<\/span> =<\/span> TIM_ICPolarity_Rising<\/span>; \/* \u4e0a\u5347\u6cbf\u6355\u83b7 *\/<\/span><\/span>\r\nTIM5_ICInitStructure<\/span>.TIM_ICSelection<\/span> =<\/span> TIM_ICSelection_DirectTI<\/span>; \/\/\u6620\u5c04\u5230TI1\u4e0a<\/span><\/span>\r\nTIM5_ICInitStructure<\/span>.TIM_ICPrescaler<\/span> =<\/span> TIM_ICPSC_DIV1<\/span>;     \/\/\u914d\u7f6e\u8f93\u5165\u5206\u9891,\u4e0d\u5206\u9891 <\/span><\/span>\r\nTIM5_ICInitStructure<\/span>.TIM_ICFilter<\/span> =<\/span> 0x00<\/span>;            \/\/IC1F=0000 \u914d\u7f6e\u8f93\u5165\u6ee4\u6ce2\u5668 \u4e0d\u6ee4\u6ce2<\/span><\/span>\r\nTIM_ICInit<\/span>(TIM5<\/span>, &<\/span>TIM5_ICInitStructure<\/span>);<\/span>\r\n\r\nTIM_ITConfig<\/span>(TIM5<\/span>,TIM_IT_Update<\/span>|<\/span>TIM_IT_CC1<\/span>,ENABLE<\/span>); \/* \u5141\u8bb8\u66f4\u65b0(\u6ea2\u51fa)\u4e2d\u65ad ,\u5141\u8bb8CC1IE\u6355\u83b7\u4e2d\u65ad *\/<\/span> <\/span>\r\n\r\nTIM_Cmd<\/span>(TIM5<\/span>,ENABLE<\/span> ); \/\/\u4f7f\u80fd\u5b9a\u65f6\u56685<\/span><\/span><\/pre>\n
                          \n
                        • \n

                          \n\t\t\t\u5173\u4e8e\u914d\u7f6eCCMR1\u3001CCER\u5bc4\u5b58\u5668<\/span><\/p>\n<\/li>\n<\/ul>\n

                          \n\tCCMR1:<\/span><\/p>\n

                          \n\t\"poYBAGDQvD-Acon1AABGDNkRr5A476.png\"<\/span><\/p>\n

                          \n\tCCER:<\/span>\"pYYBAGDQvECAG18AAAAqgbJouDE128.png\"<\/span><\/p>\n

                          \n\tTIM_ICInit<\/code><\/span>\u51fd\u6570\u5bf9\u5e94\u4e8e\u8f93\u5165\u901a\u9053\u7684\u521d\u59cb\u5316\uff0c\u5176\u5b9e\u5c31\u662f\u64cd\u4f5c<\/span>CCMR1<\/code><\/span>\u3001<\/span>CCER<\/code><\/span>\u5bc4\u5b58\u5668\uff1a<\/span><\/p>\n

                          \r\nvoid<\/span> TIM_ICInit<\/span>(TIM_TypeDef<\/span>*<\/span> TIMx<\/span>, TIM_ICInitTypeDef<\/span>*<\/span> TIM_ICInitStruct<\/span>)<\/span>\r\n{<\/span>\r\n if<\/u><\/span> (TIM_ICInitStruct<\/span>-><\/span>TIM_Channel<\/span> ==<\/span> TIM_Channel_1<\/span>)<\/span>\r\n {  \/* TI1 \u914d\u7f6e *\/<\/span><\/span>\r\n   TI1_Config<\/span>(TIMx<\/span>, TIM_ICInitStruct<\/span>-><\/span>TIM_ICPolarity<\/span>,<\/span>\r\n         TIM_ICInitStruct<\/span>-><\/span>TIM_ICSelection<\/span>,<\/span>\r\n         TIM_ICInitStruct<\/span>-><\/span>TIM_ICFilter<\/span>);<\/span>\r\n   \/* \u8bbe\u7f6e\u4e2d\u65ad\u6355\u83b7\u9884\u5206\u9891\u503c *\/<\/span><\/span>\r\n   TIM_SetIC1Prescaler<\/span>(TIMx<\/span>, TIM_ICInitStruct<\/span>-><\/span>TIM_ICPrescaler<\/span>);<\/span>\r\n }<\/span>\r\n else<\/span> if<\/span> (TIM_ICInitStruct<\/span>-><\/span>TIM_Channel<\/span> ==<\/span> TIM_Channel_2<\/span>)<\/span>\r\n {<\/span>\r\n   \/*\u7701\u7565...*\/<\/span><\/span>\r\n }<\/span>\r\n}<\/span>\r\n\r\nstatic<\/span> void<\/span> TI1_Config<\/span>(TIM_TypeDef<\/span>*<\/span> TIMx<\/span>, uint16_t<\/span> TIM_ICPolarity<\/span>, uint16_t<\/span> TIM_ICSelection<\/span>,uint16_t<\/span> TIM_ICFilter<\/span>)<\/span>\r\n{<\/span>\r\n uint16_t<\/span> tmpccmr1<\/span> =<\/span> 0<\/span>, tmpccer<\/span> =<\/span> 0<\/span>;<\/span>\r\n\r\n \/* \u5173\u95ed\u901a\u90531: \u590d\u4f4dCC1E\u4f4d *\/<\/span><\/span>\r\n TIMx<\/span>-><\/span>CCER<\/span> &=<\/span> (uint16_t<\/span>)~TIM_CCER_CC1E<\/span>;<\/span>\r\n tmpccmr1<\/span> =<\/span> TIMx<\/span>-><\/span>CCMR1<\/span>;<\/span>\r\n tmpccer<\/span> =<\/span> TIMx<\/span>-><\/span>CCER<\/span>;<\/span>\r\n\r\n \/* \u901a\u8fc7\u8bbe\u7f6eCC1S\u9009\u62e9\u4e3a\u8f93\u5165\u6a21\u5f0f\uff0c \u5e76\u914d\u7f6e\u6ee4\u6ce2\u5668 *\/<\/span><\/span>\r\n tmpccmr1<\/span> &=<\/span> ((uint16_t<\/span>)~TIM_CCMR1_CC1S<\/span>) &<\/span> ((uint16_t<\/span>)~TIM_CCMR1_IC1F<\/span>);<\/span>\r\n tmpccmr1<\/span> |=<\/span> (uint16_t<\/span>)(TIM_ICSelection<\/span> |<\/span> (uint16_t<\/span>)(TIM_ICFilter<\/span> <<<\/span> (uint16_t<\/span>)4<\/span>));<\/span>\r\n\r\n \/* \u9009\u62e9CC1P\u6781\u6027\u5e76\u8bbe\u7f6eCC1E\u4f4d *\/<\/span><\/span>\r\n tmpccer<\/span> &=<\/span> (uint16_t<\/span>)~<\/span>(TIM_CCER_CC1P<\/span> |<\/span> TIM_CCER_CC1NP<\/span>);<\/span>\r\n tmpccer<\/span> |=<\/span> (uint16_t<\/span>)(TIM_ICPolarity<\/span> |<\/span> (uint16_t<\/span>)TIM_CCER_CC1E<\/span>);<\/span>\r\n\r\n \/* \u5199\u6570\u636e\u5230 TIMx \u7684CCMR1 \u548c CCER \u5bc4\u5b58\u5668 *\/<\/span><\/span>\r\n TIMx<\/span>-><\/span>CCMR1<\/span> =<\/span> tmpccmr1<\/span>;<\/span>\r\n TIMx<\/span>-><\/span>CCER<\/span> =<\/span> tmpccer<\/span>;<\/span>\r\n}<\/span>\r\n\r\nvoid<\/span> TIM_SetIC1Prescaler<\/span>(TIM_TypeDef<\/span>*<\/span> TIMx<\/span>, uint16_t<\/span> TIM_ICPSC<\/span>)<\/span>\r\n{<\/span>\r\n TIMx<\/span>-><\/span>CCMR1<\/span> &=<\/span> (uint16_t<\/span>)~TIM_CCMR1_IC1PSC<\/span>; \/* \u590d\u4f4dIC1PSC\u4f4d *\/<\/span><\/span>\r\n TIMx<\/span>-><\/span>CCMR1<\/span> |=<\/span> TIM_ICPSC<\/span>;          \/* \u8bbe\u7f6eIC1PSC\u503c *\/<\/span><\/span>\r\n}<\/span><\/pre>\n
                            \n
                          • \n

                            \n\t\t\t\u5173\u4e8e\u914d\u7f6eDIER\u5bc4\u5b58\u5668<\/span><\/p>\n<\/li>\n<\/ul>\n

                            \n\t\"pYYBAGDQvEGAZLeLAAAkg5HrLUE613.png\"<\/span><\/p>\n

                            \n\tTIM_ITConfig<\/code><\/span>\u51fd\u6570\u5bf9\u4e8e\u4e2d\u65ad\u7684\u5f00\u542f\uff0c\u5176\u5b9e\u5c31\u662f\u64cd\u4f5c<\/span>DIER<\/code><\/span>\u5bc4\u5b58\u5668\uff1a<\/span><\/p>\n

                            \r\nvoid<\/span> TIM_ITConfig<\/span>(TIM_TypeDef<\/span>*<\/span> TIMx<\/span>, uint16_t<\/span> TIM_IT<\/span>, FunctionalState<\/span> NewState<\/span>)<\/span>\r\n{ <\/span>\r\n if<\/span> (NewState<\/span> !=<\/span> DISABLE<\/span>)<\/span>\r\n {  \/* \u4f7f\u80fd\u4e2d\u65ad *\/<\/span><\/span>\r\n   TIMx<\/span>-><\/span>DIER<\/span> |=<\/span> TIM_IT<\/span>;<\/span>\r\n }<\/span>\r\n else<\/span><\/span>\r\n {  \/* \u5931\u80fd\u4e2d\u65ad *\/<\/span><\/span>\r\n   TIMx<\/span>-><\/span>DIER<\/span> &=<\/span> (uint16_t<\/span>)~TIM_IT<\/span>;<\/span>\r\n }<\/span>\r\n}<\/span><\/pre>\n

                            \n\t <\/p>\n

                            \n\t4.1.4 \u5b9a\u65f6\u5668\u4e2d\u65ad\u521d\u59cb\u5316<\/span><\/h3>\n

                            \n\t\u5b9a\u65f6\u5668\u4e2d\u65ad\u7684\u4f7f\u80fd\u8bbe\u7f6e\u5df2\u5728\u4e0a\u9762\u7684\u5b9a\u65f6\u5668\u914d\u7f6e\u4e2d\u8bbe\u7f6e\uff0c\u8fd9\u91cc\u53ea\u662f\u8fdb\u884c\u5e38\u89c4\u7684\u914d\u7f6e\u5b9a\u65f6\u5668\u4e2d\u65ad\u7684\u4f18\u5148\u7ea7\uff1a<\/span><\/p>\n

                            \r\n\/*\u5b9a\u65f6\u5668\u4e2d\u65ad\u914d\u7f6e*\/<\/span><\/span>\r\nNVIC_InitStructure<\/span>.NVIC_IRQChannel<\/span> =<\/span> TIM5_IRQn<\/span>;<\/span>\r\nNVIC_InitStructure<\/span>.NVIC_IRQChannelPreemptionPriority<\/span>=<\/span>2<\/span>; \/\/\u62a2\u5360\u4f18\u5148\u7ea73<\/span><\/span>\r\nNVIC_InitStructure<\/span>.NVIC_IRQChannelSubPriority<\/span> =<\/span>0<\/span>; \/\/\u5b50\u4f18\u5148\u7ea73<\/span><\/span>\r\nNVIC_InitStructure<\/span>.NVIC_IRQChannelCmd<\/span> =<\/span> ENABLE<\/span>;  \/\/IRQ\u901a\u9053\u4f7f\u80fd<\/span><\/span>\r\nNVIC_Init<\/span>(&<\/span>NVIC_InitStructure<\/span>);           \/\/\u6839\u636e\u6307\u5b9a\u7684\u53c2\u6570\u521d\u59cb\u5316NVIC\u5bc4\u5b58\u5668<\/span><\/span><\/pre>\n

                            \n\t <\/p>\n

                            \n\t4.2 \u5b9a\u65f6\u5668\u4e2d\u65ad\u670d\u52a1\u51fd\u6570<\/span><\/h2>\n

                            \n\t\u6b64\u5904\u7528\u5230\u4e86\u4e24\u4e2a\u5168\u5c40\u53d8\u91cf\uff0c\u7528\u4e8e\u8f85\u52a9\u5b9e\u73b0\u9ad8\u7535\u5e73\u6355\u83b7\u3002\u5176\u4e2d\uff1a<\/span><\/p>\n

                              \n
                            • \n

                              \n\t\t\tTIM5CH1_CAPTURE_VAL<\/code><\/span>\u7528\u6765\u8bb0\u5f55\u6355\u83b7\u5230\u4e0b\u964d\u6cbf\u7684\u65f6\u5019 TIM5_CNT\u7684\u503c\u3002<\/span><\/p>\n<\/li>\n

                            • \n

                              \n\t\t\tTIM5CH1_CAPTURE_STA<\/code><\/span>\u7528\u6765\u8bb0\u5f55\u6355\u83b7\u72b6\u6001\uff0c\u6211\u4eec\u628a\u5b83\u5f53\u6210\u4e00\u4e2a\u5bc4\u5b58\u5668\u90a3\u6837\u6765\u4f7f\u7528 \u3002\u5176\u5404\u4f4d\u63cf\u8ff0\u4e0b\uff1a<\/span><\/p>\n<\/li>\n<\/ul>\n

                              \n\t\"poYBAGDQvEKAFfL2AAEK03xP02U575.png\"<\/span><\/p>\n

                              \r\nu8<\/span> TIM5CH1_CAPTURE_STA<\/span>=<\/span>0<\/span>; \/\/\u8f93\u5165\u6355\u83b7\u72b6\u6001\uff08\u5f53\u4e2d\u4e00\u4e2a\u81ea\u5236\u7684\u5bc4\u5b58\u5668\u4f7f\u7528\uff0c\u521d\u59cb\u4e3a0\uff09 <\/span><\/span>\r\nu32<\/span> TIM5CH1_CAPTURE_VAL<\/span>; \/\/\u8f93\u5165\u6355\u83b7\u503c(TIM2\/TIM5\u662f32\u4f4d)<\/span><\/span>\r\n\r\n\/**<\/span><\/span>\r\n* @brief \u5b9a\u65f6\u56685\u4e2d\u65ad\u670d\u52a1\u7a0b\u5e8f<\/span><\/span>\r\n*\/<\/span><\/span>\r\nvoid<\/span> TIM5_IRQHandler<\/span>(void<\/span>)<\/span>\r\n{  <\/span>\r\n if<\/span>((TIM5CH1_CAPTURE_STA<\/span>&<\/span>0X80<\/span>)==<\/span>0<\/span>)\/\/\u8fd8\u672a\u6210\u529f\u6355\u83b7 (1000 0000)<\/span><\/span>\r\n {<\/span>\r\n \/*\u5b9a\u65f6\u5668\u6ea2\u51fa\u4e2d\u65ad*\/<\/span><\/span>\r\n if<\/span>(TIM_GetITStatus<\/span>(TIM5<\/span>, TIM_IT_Update<\/span>) !=<\/span> RESET<\/span>)<\/span>\r\n {   <\/span>\r\n  if<\/span>(TIM5CH1_CAPTURE_STA<\/span>&<\/span>0X40<\/span>)\/* \u4e4b\u524d\u6807\u8bb0<\/u>\u4e86\u5f00\u59cb\u4fe1\u53f7(0100 0000) *\/<\/span><\/span>\r\n  {<\/span>\r\n  if<\/span>((TIM5CH1_CAPTURE_STA<\/span>&<\/span>0X3F<\/span>)==<\/span>0X3F<\/span>) \/* \u9ad8\u7535\u5e73\u592a\u957f\u4e86,\u8ba1\u6570\u6ea2\u51fa\u4e86 (0011 1111) *\/<\/span><\/span>\r\n  {<\/span>\r\n   TIM5CH1_CAPTURE_STA<\/span>|=<\/span>0X80<\/span>;  \/* (\u5f3a\u5236)\u6807\u8bb0\u6210\u529f\u6355\u83b7\u4e86\u4e00\u6b21 (1000 0000) *\/<\/span><\/span>\r\n   TIM5CH1_CAPTURE_VAL<\/span>=<\/span>0XFFFFFFFF<\/span>; \/* \u56e0\u4e3a\u6ea2\u51fa\u6b21\u6570N\u4e0d\u80fd\u518d\u52a0\u4e86\uff0c\u5c31\u5c06\u5f53\u524d\u7684\u6355\u83b7\u503c\u8bbe\u7f6e\u4e3a32\u4f4d\u7684\u6700\u5927\u503c\uff0c\u7b49\u6548Nmax+1*\/<\/span><\/span>\r\n  }<\/span>\r\n  else<\/span> \/* \u6b63\u5e38\u60c5\u51b5\u662f\u4e0d\u4f1a\u6ea2\u51fa\uff0c\u6700\u7ec8\u5f97\u51fa\u6b63\u786e\u7684\u9ad8\u7535\u5e73\u65f6\u95f4 *\/<\/span><\/span>\r\n  {<\/span>\r\n   TIM5CH1_CAPTURE_STA<\/span>++<\/span>; \/* \u7d2f\u8ba1\u5b9a\u65f6\u5668\u6ea2\u51fa\u6b21\u6570N *\/<\/span><\/span>\r\n  }<\/span>\r\n  }<\/span>\r\n  else<\/span><\/span>\r\n  {<\/span>\r\n  \/* \u8fd8\u6ca1\u6709\u6355\u83b7\u5230\u4fe1\u53f7\u65f6\uff0c\u5b9a\u65f6\u5668\u6ea2\u51fa\u540e\u4ec0\u4e48\u4e5f\u4e0d\u505a\uff0c\u81ea\u5df1\u6e05\u96f6\u7ee7\u7eed\u8ba1\u6570\u5373\u53ef *\/<\/span><\/span>\r\n  }<\/span>\r\n }<\/span>\r\n <\/span>\r\n \/*\u6355\u83b71\u53d1\u751f\u6355\u83b7\u4e8b\u4ef6*\/<\/span><\/span>\r\n if<\/span>(TIM_GetITStatus<\/span>(TIM5<\/span>, TIM_IT_CC1<\/span>) !=<\/span> RESET<\/span>)<\/span>\r\n { <\/span>\r\n  \/*\u6355\u83b7\u5230\u4e00\u4e2a\u4e0b\u964d\u6cbf(\u7ed3\u675f\u4fe1\u53f7)*\/<\/span><\/span>\r\n  if<\/span>(TIM5CH1_CAPTURE_STA<\/span>&<\/span>0X40<\/span>) \/* \u4e4b\u524d\u6807\u8bb0\u4e86\u5f00\u59cb\u4fe1\u53f7(0100 0000) *\/<\/span>   <\/span>\r\n  {   <\/span>\r\n  TIM5CH1_CAPTURE_STA<\/span>|=<\/span>0X80<\/span>;           \/* \u6807\u8bb0\u6210\u529f\u6355\u83b7\u5230\u4e00\u6b21\u9ad8\u7535\u5e73\u8109\u5bbd (1000 0000) *\/<\/span><\/span>\r\n  TIM5CH1_CAPTURE_VAL<\/span>=<\/span>TIM_GetCapture1<\/span>(TIM5<\/span>);     \/* \u83b7\u53d6\u5f53\u524d\u7684\u6355\u83b7\u503c *\/<\/span><\/span>\r\n   TIM_OC1PolarityConfig<\/span>(TIM5<\/span>,TIM_ICPolarity_Rising<\/span>); \/* CC1P=0 \u91cd\u65b0\u8bbe\u7f6e\u4e3a\u4e0a\u5347\u6cbf\u6355\u83b7\uff0c\u7528\u4e8e\u4e0b\u6b21\u6355\u6349\u4fe1\u53f7 *\/<\/span><\/span>\r\n  }   <\/span>\r\n  \/*\u8fd8\u672a\u5f00\u59cb,\u7b2c\u4e00\u6b21\u6355\u83b7 \u4e0a\u5347\u6cbf(\u8d77\u59cb\u4fe1\u53f7) *\/<\/span><\/span>\r\n  else<\/span>     <\/span>\r\n  {<\/span>\r\n  TIM5CH1_CAPTURE_STA<\/span>=<\/span>0<\/span>;  \/* \u6e05\u7a7a \u6355\u83b7\u72b6\u6001\u5bc4\u5b58\u5668 *\/<\/span><\/span>\r\n  TIM5CH1_CAPTURE_VAL<\/span>=<\/span>0<\/span>;     \/* \u6e05\u7a7a \u6355\u83b7\u503c *\/<\/span><\/span>\r\n  TIM5CH1_CAPTURE_STA<\/span>|=<\/span>0X40<\/span>; \/* \u6807\u8bb0\u6355\u83b7\u5230\u4e86\u4e0a\u5347\u6cbf (0100 0000) *\/<\/span><\/span>\r\n  <\/span>\r\n  TIM_Cmd<\/span>(TIM5<\/span>,DISABLE<\/span> );   \/* \u5173\u95ed\u5b9a\u65f6\u56685 *\/<\/span><\/span>\r\n   TIM_SetCounter<\/span>(TIM5<\/span>,0<\/span>);     \/* \u6e05\u7a7aCNT\uff0c\u91cd\u65b0\u4ece0\u5f00\u59cb\u8ba1\u6570 *\/<\/span><\/span>\r\n   TIM_OC1PolarityConfig<\/span>(TIM5<\/span>,TIM_ICPolarity_Falling<\/span>); \/* CC1P=1 \u8bbe\u7f6e\u4e3a\u4e0b\u964d\u6cbf\u6355\u83b7 *\/<\/span><\/span>\r\n  TIM_Cmd<\/span>(TIM5<\/span>,ENABLE<\/span> );     \/* \u4f7f\u80fd\u5b9a\u65f6\u56685 *\/<\/span><\/span>\r\n  }   <\/span>\r\n }          <\/span>\r\n }<\/span>\r\n TIM_ClearITPendingBit<\/span>(TIM5<\/span>, TIM_IT_CC1<\/span>|<\/span>TIM_IT_Update<\/span>); \/\/\u6e05\u9664\u4e2d\u65ad\u6807\u5fd7\u4f4d<\/span><\/span>\r\n}<\/span><\/pre>\n

                              \n\t\u518d\u6765\u5bf9\u6bd4\u4e00\u4e0b\u8fd9\u5f20\u56fe\uff1a<\/span><\/p>\n

                              \n\t\"poYBAGDQvDmAVWWNAAELc5qfGa4389.png\"<\/span><\/p>\n

                                \n
                              • \n

                                \n\t\t\t\u521d\u59cb\u5316\u65f6\u8bbe\u7f6e\u4e3a\u4e0a\u5347\u6cbf\u89e6\u53d1\uff0c\u89e6\u53d1\u540e\uff08\u8d77\u59cb\u4fe1\u53f7\uff09\uff0c\u6e05\u7a7aCNT\uff0c\u91cd\u65b0\u4ece0\u5f00\u59cb\u8ba1\u6570\uff0c\u5e76\u8bbe\u7f6e\u4e3a\u4e0b\u964d\u6cbf\u6355\u83b7<\/span><\/p>\n<\/li>\n

                              • \n

                                \n\t\t\t\u5728\u4e4b\u540e\u7684\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u4f1a\u6709\u591a\u6b21\u5b9a\u65f6\u5668\u8ba1\u6570\u6ea2\u51fa\uff0c\u5373TIM5CH1_CAPTURE_STA++\uff08\u4f7f\u7528\u4f4e6\u4f4d\uff09\uff0c\u4e5f\u5373N\u7684\u503c<\/span><\/p>\n<\/li>\n

                              • \n

                                \n\t\t\t\u6700\u540e\u6355\u6349\u5230\u4e0b\u964d\u6cbf\uff08\u7ed3\u675f\u4fe1\u53f7\uff09\uff0cTIM5CH1_CAPTURE_VAL\u83b7\u53d6\u5f53\u524dCNT\u7684\u503c\uff0c\u4e5f\u5373CCRx2\u7684\u503c<\/span><\/p>\n<\/li>\n<\/ul>\n

                                \n\t\u518d\u770b\u4e3b\u51fd\u6570\u4e2d\uff1a<\/span><\/p>\n

                                \r\nwhile<\/span>(1<\/span>) <\/span>\r\n{<\/span>\r\n  \/* \u6210\u529f\u6355\u83b7\u5230\u4e86\u4e00\u6b21\u9ad8\u7535\u5e73 (1000 0000) *\/<\/span><\/span>\r\n  if<\/span>(TIM5CH1_CAPTURE_STA<\/span>&<\/span>0X80<\/span>)    <\/span>\r\n  {<\/span>\r\n    temp<\/span>=<\/span>TIM5CH1_CAPTURE_STA<\/span>&<\/span>0X3F<\/span>; \/* \u83b7\u53d6\u6ea2\u51fa\u7684\u6b21\u6570N (0011 1111) *\/<\/span><\/span>\r\n    temp<\/span>*=<\/span>0XFFFFFFFF<\/span>;   \/* \u6ea2\u51fa\u65f6\u95f4\u603b\u548c = N*\u6ea2\u51fa\u8ba1\u6570\u503c *\/<\/span><\/span>\r\n    temp<\/span>+=<\/span>TIM5CH1_CAPTURE_VAL<\/span>; \/* \u603b\u7684\u9ad8\u7535\u5e73\u65f6\u95f4 = \u6ea2\u51fa\u65f6\u95f4\u603b\u548c + \u4e0b\u964d\u6cbf\u65f6\u7684\u8ba1\u6570\u503c*\/<\/span><\/span>\r\n\r\n    printf<\/span>("HIGH:%lld us\\r\\n"<\/span>,temp<\/span>); \/\/\u6253\u5370\u603b\u7684\u9ad8\u70b9\u5e73\u65f6\u95f4<\/span><\/span>\r\n    TIM5CH1_CAPTURE_STA<\/span>=<\/span>0<\/span>;  \/\/\u5f00\u542f\u4e0b\u4e00\u6b21\u6355\u83b7<\/span><\/span>\r\n  }<\/span>\r\n}<\/span><\/pre>\n

                                \n\t\u5f53\u68c0\u67e5<\/span>TIM5CH1_CAPTURE_STA<\/code><\/span>\u4e3a\u6355\u83b7\u52301\u6b21\u9ad8\u7535\u5e73\u540e\uff0c\u6253\u5370\u9ad8\u7535\u5e73\u7684\u6301\u7eed\u65f6\u95f4\uff1a<\/span><\/p>\n

                                  \n
                                • \n

                                  \n\t\t\t\u603b\u7684\u9ad8\u7535\u5e73\u65f6\u95f4 =<\/span>N<\/strong><\/span>(TIM5CH1_CAPTURE_STA\u7684\u4f4e6\u4f4d) * <\/span>ARR<\/strong><\/span>(\u6ea2\u51fa\u8ba1\u6570\u503c)+ <\/span>CCRx2<\/strong><\/span>(\u4e0b\u964d\u6cbf\u65f6\u7684\u8ba1\u6570\u503c)<\/span><\/p>\n<\/li>\n<\/ul>\n

                                  \n\t <\/p>\n

                                  \n\t <\/p>\n

                                  \n

                                  \n\t\t\u9644\uff1a\u4e00\u4e9b\u5bc4\u5b58\u5668\u7b80\u5199\u7684\u5168\u79f0<\/span><\/p>\n

                                    \n
                                  • \n

                                    \n\t\t\t\tARR\uff1aauto-reload register \u81ea\u52a8\u91cd\u8f7d\u5bc4\u5b58\u5668<\/span><\/p>\n<\/li>\n

                                  • \n

                                    \n\t\t\t\tCCR\uff1acapture\/compare register \u6355\u83b7\/\u6bd4\u8f83\u5bc4\u5b58\u5668<\/span><\/p>\n<\/li>\n

                                  • \n

                                    \n\t\t\t\tPSC\uff1aprescaler \u9884\u5206\u9891\u5668<\/span><\/p>\n<\/li>\n

                                  • \n

                                    \n\t\t\t\tCNT\uff1acounter \u8ba1\u6570\u5668<\/span><\/p>\n<\/li>\n

                                  • \n

                                    \n\t\t\t\tSR\uff1astatus register \u72b6\u6001\u5bc4\u5b58\u5668<\/span><\/p>\n<\/li>\n

                                  • \n

                                    \n\t\t\t\tCCMR\uff1acapture\/compare mode register \u6355\u83b7\/\u6bd4\u8f83\u6a21\u5f0f\u5bc4\u5b58\u5668<\/span><\/p>\n

                                      \n
                                    • \n

                                      \n\t\t\t\t\t\tCC1S\uff1aCapture\/Compare 1 selection \u6355\u83b7\/\u6bd4\u8f831\u6a21\u5f0f\u9009\u62e9<\/span><\/p>\n<\/li>\n

                                    • \n

                                      \n\t\t\t\t\t\tOC1M\uff1a Output compare 1 mode \u8f93\u51fa\u6bd4\u8f831\u6a21\u5f0f<\/span><\/p>\n<\/li>\n

                                    • \n

                                      \n\t\t\t\t\t\tOC1PE\uff1aOutput compare 1 preload enable \u8f93\u51fa\u6bd4\u8f831\u9884\u88c5\u8f7d\u4f7f\u80fd<\/span><\/p>\n<\/li>\n

                                    • \n

                                      \n\t\t\t\t\t\tIC1F\uff1aInput capture 1 filter \u8f93\u5165\u6355\u83b71\u6ee4\u6ce2\u5668<\/span><\/p>\n<\/li>\n

                                    • \n

                                      \n\t\t\t\t\t\tIC1PSC\uff1aInput capture 1 prescaler \u8f93\u5165\u6355\u83b71\u9884\u5206\u9891\u5668<\/span><\/p>\n<\/li>\n<\/ul>\n<\/li>\n

                                    • \n

                                      \n\t\t\t\tCCER\uff1acapture\/compare enable register \u6355\u83b7\/\u6bd4\u8f83\u4f7f\u80fd\u5bc4\u5b58\u5668<\/span><\/p>\n

                                        \n
                                      • \n

                                        \n\t\t\t\t\t\tCC1P\uff1aCapture\/Comparex output Polarity \u6355\u83b7 \/\u6bd4\u8f831\u8f93\u51fa\u6781\u6027<\/span><\/p>\n<\/li>\n

                                      • \n

                                        \n\t\t\t\t\t\tCC1E\uff1aCapture\/Comparex output enable \u6355\u83b7 \/\u6bd4\u8f831\u8f93\u51fa\u4f7f\u80fd<\/span><\/p>\n<\/li>\n<\/ul>\n<\/li>\n

                                      • \n

                                        \n\t\t\t\tSMCR\uff1aslave mode control register \u4ece\u6a21\u5f0f\u63a7\u5236\u5bc4\u5b58\u5668<\/span><\/p>\n<\/li>\n

                                      • \n

                                        \n\t\t\t\tDCR\uff1aDMA control register DMA \u63a7\u5236\u5bc4\u5b58\u5668<\/span><\/p>\n<\/li>\n

                                      • \n

                                        \n\t\t\t\tDIER\uff1aDMA\/Interrupt enable register DMA\/\u4e2d\u65ad\u4f7f\u80fd\u5bc4\u5b58\u5668<\/span><\/p>\n<\/li>\n

                                      • \n

                                        \n\t\t\t\tDMAR\uff1aDMA address for full transfer \u5168\u4f20\u8f93 DMA \u5730\u5740<\/span><\/p>\n<\/li>\n

                                      • \n

                                        \n\t\t\t\tOR\uff1aoption register \u9009\u9879\u5bc4\u5b58\u5668<\/span><\/p>\n<\/li>\n<\/ul>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

                                        1 \u95ee\u9898\u5f15\u51fa \u5728 \u5355\u7247\u673a \u4e0e\u5d4c\u5165\u5f0f\u5f00\u53d1\u4e2d\uff0c\u67d0\u4e9b\u573a\u666f\u9700\u8981\u6355\u83b7 \u4f20\u611f\u5668 \u7684\u9ad8\u7535\u5e73\uff08\u6216\u4f4e\u7535\u5e73\uff09\u4fe1\u53f7\u7684\u6301\u7eed\u65f6\u95f4\uff0c\u5982 \u7ea2\u5916 \u89e3\u7801\u4fe1\u53f7\u3001 \u7f16\u7801\u5668 \u8f93\u5165\u4fe1\u53f7\u7b49\u3002 \u5982\u4e0b\u56fe\uff0c\u4ee5\u5355\u4e00\u7684\u4e00\u6bb5\u9ad8\u7535\u5e73\u8f93\u5165<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"_links":{"self":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/3207"}],"collection":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3207"}],"version-history":[{"count":0,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/3207\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3207"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}