{"id":112505,"date":"2026-10-03T20:49:38","date_gmt":"2026-10-03T12:49:38","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/112505.html"},"modified":"2026-10-03T20:49:38","modified_gmt":"2026-10-03T12:49:38","slug":"%e3%80%90stm32%e3%80%91-%e9%98%b6%e6%ae%b5%e6%80%a7%e9%9d%a2%e8%af%95%e9%a2%98%ef%bc%88%e7%99%be%e9%a2%98%e5%a4%8d%e4%b9%a0%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/112505.html","title":{"rendered":"\u3010STM32\u3011 \u9636\u6bb5\u6027\u9762\u8bd5\u9898\uff08\u767e\u9898\u590d\u4e60\uff09"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1600\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261003124930-6ac0f9da7bb3a.png\" width=\"2848\" \/><\/p>\n<hr \/>\n<h2><span style=\"color:#a2e043\"><span style=\"background-color:#7b7f82\">\u00a0 STM32 \u5168\u5957\u5916\u8bbe\u9762\u8bd5\u9898\u5e93\u00a0\u00a0<\/span><\/span><\/h2>\n<h2><span style=\"color:#0d0016\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"480\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261003124935-6ac0f9df94466.png\" width=\"860\" \/><\/span><span style=\"color:#1a439c\">\u6a21\u5757\u4e00 \u00b7 GPIO&#xff08;LED \u8f93\u51fa\u3001\u6309\u952e\u8f93\u5165&#xff09;G1\u2013G10<\/span><\/h2>\n<p><span style=\"color:#b95514\">G1. STM32 \u7684 8 \u79cd GPIO \u6a21\u5f0f\u5206\u522b\u662f\u4ec0\u4e48&#xff1f;\u5404\u7528\u4e8e\u4ec0\u4e48\u573a\u666f&#xff1f;&#xff08;\u5fc5\u8003&#xff09;<\/span><\/p>\n<table>\n<tr><span style=\"color:#0d0016\">\u6a21\u5f0f<\/span><span style=\"color:#0d0016\">\u7279\u70b9<\/span><span style=\"color:#0d0016\">\u5178\u578b\u7528\u9014<\/span><\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#0d0016\">\u8f93\u5165\u6d6e\u7a7a<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u9ad8\u963b&#xff0c;\u7535\u5e73\u5b8c\u5168\u7531\u5916\u90e8\u51b3\u5b9a<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u65e0\u4e0a\u4e0b\u62c9\u7684\u4fe1\u53f7\u76d1\u6d4b<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u8f93\u5165\u4e0a\u62c9<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u5185\u90e8\u4e0a\u62c9&#xff0c;\u9ed8\u8ba4\u8bfb\u9ad8<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u6309\u952e\u6309\u4e0b\u63a5\u5730\u68c0\u6d4b<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u8f93\u5165\u4e0b\u62c9<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u5185\u90e8\u4e0b\u62c9&#xff0c;\u9ed8\u8ba4\u8bfb\u4f4e<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u6309\u952e\u6309\u4e0b\u63a5 VCC \u68c0\u6d4b<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u6a21\u62df\u8f93\u5165<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u5173\u95ed\u6570\u5b57\u7f13\u51b2<\/span><\/td>\n<td><span style=\"color:#0d0016\">ADC \u91c7\u6837<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u8f93\u51fa\u63a8\u633d<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u5f3a\u9a71\u52a8\u9ad8\/\u4f4e\u7535\u5e73<\/span><\/td>\n<td><span style=\"color:#0d0016\">LED\u3001\u666e\u901a\u6570\u5b57\u8f93\u51fa<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u8f93\u51fa\u5f00\u6f0f<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u53ea\u80fd\u62c9\u4f4e&#xff0c;\u9ad8\u7535\u5e73\u9760\u5916\u90e8\u4e0a\u62c9<\/span><\/td>\n<td><span style=\"color:#0d0016\">I2C\u3001\u7535\u5e73\u8f6c\u6362\u3001\u7ebf\u4e0e<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u590d\u7528\u63a8\u633d<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u5916\u8bbe\u9a71\u52a8\u5f15\u811a<\/span><\/td>\n<td><span style=\"color:#0d0016\">USART TX\u3001SPI MOSI\/SCK<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u590d\u7528\u5f00\u6f0f<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u5916\u8bbe\u5f00\u6f0f\u8f93\u51fa<\/span><\/td>\n<td><span style=\"color:#0d0016\">I2C SCL\/SDA<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li><span style=\"color:#0d0016\">\u8ffd\u95ee&#xff1a;\u5f00\u6f0f\u8f93\u51fa\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u76f4\u63a5\u8f93\u51fa\u9ad8\u7535\u5e73&#xff1f;\u2192 \u5185\u90e8\u65e0\u4e0a\u62c9 MOS&#xff0c;\u9ad8\u7535\u5e73\u5fc5\u987b\u5916\u90e8\u4e0a\u62c9\u7535\u963b&#xff0c;\u5426\u5219\u60ac\u7a7a\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">G2. \u63a8\u633d\u8f93\u51fa\u548c\u5f00\u6f0f\u8f93\u51fa\u7684\u672c\u8d28\u533a\u522b&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u63a8\u633d&#xff1a;P-MOS &#043; N-MOS \u4e92\u8865&#xff0c;\u80fd\u4e3b\u52a8\u8f93\u51fa 0 \u548c 1&#xff0c;\u9a71\u52a8\u80fd\u529b\u5f3a&#xff0c;\u4f46\u4e24\u4e2a IO \u4e0d\u80fd\u7ebf\u6216\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u5f00\u6f0f&#xff1a;\u53ea\u6709 N-MOS&#xff0c;\u8f93\u51fa 0 \u62c9\u4f4e\u3001\u8f93\u51fa 1 \u91ca\u653e&#xff08;\u9ad8\u963b&#xff09;&#xff0c;\u9760\u4e0a\u62c9\u7535\u963b\u62c9\u9ad8&#xff1b;\u591a\u8bbe\u5907\u53ef\u4ee5\u7ebf\u4e0e&#xff08;I2C \u4ef2\u88c1\u539f\u7406&#xff09;&#xff0c;\u8fd8\u80fd\u505a 3.3V\u21945V \u7535\u5e73\u8f6c\u6362&#xff08;\u4e0a\u62c9\u5230 5V&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8ffd\u95ee&#xff1a;<\/span><span style=\"color:#fe2c24\">\u7ebf\u4e0e\u662f\u600e\u4e48\u5b9e\u73b0\u7684&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u4efb\u4e00\u8bbe\u5907\u62c9\u4f4e SDA&#xff0c;\u603b\u7ebf\u5c31\u662f\u4f4e&#xff1b;\u90fd\u4e0d\u62c9\u5c31\u662f\u9ad8&#xff08;\u4e0a\u62c9&#xff09;&#xff0c;\u5929\u7136&#034;\u4e0e&#034;\u903b\u8f91\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">G3. \u6309\u952e\u68c0\u6d4b\u4e3a\u4ec0\u4e48\u5e38\u7528\u4e0a\u62c9\u8f93\u5165&#xff1f;\u8f6f\u4ef6\u6d88\u6296\u600e\u4e48\u505a&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u6309\u952e\u4e00\u7aef\u63a5 GND&#xff0c;\u53e6\u4e00\u7aef\u63a5 IO &#043; \u5185\u90e8\u4e0a\u62c9&#xff1a;\u677e\u5f00\u8bfb 1\u3001\u6309\u4e0b\u8bfb 0&#xff0c;\u7701\u5916\u90e8\u7535\u963b\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u673a\u68b0\u6296\u52a8 510ms&#xff0c;\u6d88\u6296&#xff1a;\u8bfb\u5230\u53d8\u5316\u540e\u00a0 \u5ef6\u65f6 1020ms \u518d\u786e\u8ba4&#xff08;\u8f6f\u4ef6&#xff09;&#xff1b;\u6216 RC \u6ee4\u6ce2\/\u65bd\u5bc6\u7279\u89e6\u53d1\u5668&#xff08;\u786c\u4ef6&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8ffd\u95ee&#xff1a;\u5ef6\u65f6\u6d88\u6296\u6709\u4ec0\u4e48\u4ee3\u4ef7&#xff1f;\u2192 \u963b\u585e\u5ef6\u65f6\u671f\u95f4 CPU \u5e72\u7b49&#xff0c;\u5b9e\u65f6\u7cfb\u7edf\u7528&#034;\u8ba1\u65f6\u5668&#043;\u72b6\u6001\u673a&#034;\u975e\u963b\u585e\u6d88\u6296\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">G4. LED \u70b9\u4eae\u6709\u4e24\u79cd\u63a5\u6cd5&#xff0c;GPIO \u914d\u7f6e\u6709\u4ec0\u4e48\u4e0d\u540c&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u4f4e\u7535\u5e73\u70b9\u4eae&#xff1a;LED \u9633\u6781\u63a5 VCC&#xff0c;\u9634\u6781\u63a5 IO&#xff08;\u4e32\u9650\u6d41\u7535\u963b&#xff09;\u2192 IO \u8f93\u51fa 0 \u4eae&#xff1b;\u63a8\u633d\u8f93\u51fa&#xff0c;\u521d\u59cb\u5316\u5148\u8f93\u51fa 1 \u907f\u514d\u4e0a\u7535\u95ea\u4eae\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u9ad8\u7535\u5e73\u70b9\u4eae&#xff1a;LED \u9633\u6781\u63a5 IO \u2192 \u8f93\u51fa 1 \u4eae&#xff0c;\u4f46\u9a71\u52a8\u7535\u6d41\u8981\u67e5\u624b\u518c&#xff08;GPIO \u704c\/\u62c9\u7535\u6d41\u7ea6 \u00b125mA&#xff0c;\u957f\u671f\u5efa\u8bae 820mA&#xff0c;\u4e32 330\u03a91k\u03a9 \u9650\u6d41&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8ffd\u95ee&#xff1a;\u4e3a\u4ec0\u4e48\u5fc5\u987b\u4e32\u9650\u6d41\u7535\u963b&#xff1f;\u2192 \u4e0d\u4e32\u5219 LED \u7535\u6d41\u53ea\u53d7\u5185\u963b\u9650\u5236&#xff0c;\u53ef\u80fd\u70e7\u6bc1 LED\/\u5f15\u811a\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">G5. GPIO \u8f93\u51fa\u901f\u5ea6&#xff08;2\/10\/50MHz&#xff09;\u5f71\u54cd\u4ec0\u4e48&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u5f71\u54cd IO \u7ffb\u8f6c\u8fb9\u6cbf\u7684\u9661\u5ced\u5ea6&#xff1a;\u901f\u5ea6\u8d8a\u9ad8\u8fb9\u6cbf\u8d8a\u9661\u3001EMI \u8d8a\u5f3a\u3001\u529f\u8017\u8d8a\u9ad8\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u9009\u578b&#xff1a;\u666e\u901a\u6309\u952e\/\u7535\u5e73\u9009\u4f4e\u901f\u6863&#xff1b;SPI \u65f6\u949f\u3001\u9ad8\u901f PWM \u9009\u9ad8\u901f\u6863&#xff1b;\u4e0d\u662f\u8d8a\u5feb\u8d8a\u597d\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8ffd\u95ee&#xff1a;\u901f\u5ea6\u6863\u4f1a\u5f71\u54cd\u5b9e\u9645\u8f93\u51fa\u9891\u7387\u4e0a\u9650\u5417&#xff1f;\u2192 \u4f1a&#xff0c;\u6863\u4f4d\u51b3\u5b9a\u8f93\u51fa\u7ea7\u9a71\u52a8\u80fd\u529b&#xff0c;\u914d\u9519\u9ad8\u901f\u4fe1\u53f7\u4f1a\u5931\u771f\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">G6. GPIO \u5e38\u7528\u5bc4\u5b58\u5668\u6709\u54ea\u4e9b&#xff1f;BSRR \u4e3a\u4ec0\u4e48\u7279\u6b8a&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">MODER&#xff08;\u6a21\u5f0f&#xff09;\u3001OTYPER&#xff08;\u8f93\u51fa\u7c7b\u578b&#xff09;\u3001OSPEEDR&#xff08;\u901f\u5ea6&#xff09;\u3001PUPDR&#xff08;\u4e0a\u4e0b\u62c9&#xff09;\u3001IDR&#xff08;\u8bfb\u8f93\u5165&#xff09;\u3001ODR&#xff08;\u5199\u8f93\u51fa&#xff09;\u3001BSRR&#xff08;\u7f6e\u4f4d\/\u590d\u4f4d&#xff09;\u3001LCKR&#xff08;\u9501\u5b9a&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">BSRR \u9ad8 16 \u4f4d\u590d\u4f4d\u3001\u4f4e 16 \u4f4d\u7f6e\u4f4d&#xff0c;\u4e00\u6b21\u5199\u64cd\u4f5c\u5b8c\u6210&#xff0c;\u539f\u5b50\u6027&#xff0c;\u4e0d\u4f1a\u88ab\u4e2d\u65ad\u6253\u65ad\u7684&#034;\u8bfb-\u6539-\u5199&#034;\u7ade\u4e89\u7834\u574f\u2014\u2014\u8fd9\u5c31\u662f\u4f4d\u5e26\u4e4b\u5916\u5feb\u901f\u6539 IO \u7684\u6807\u51c6\u624b\u6bb5\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8ffd\u95ee&#xff1a;\u4e3a\u4ec0\u4e48\u4e0d\u7528 ODR \u76f4\u63a5\u6539&#xff1f;\u2192 ODR |&#061; (1&lt;&lt;5) \u662f&#034;\u8bfb-\u6539-\u5199&#034;&#xff0c;\u4e2d\u65ad\u91cc\u4e5f\u5728\u6539\u5c31\u53ef\u80fd\u4e92\u76f8\u8986\u76d6&#xff1b;BSRR \u5355\u6b21\u5199\u65e0\u7ade\u4e89\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">G7. \u4f4d\u5e26\u64cd\u4f5c\u5bf9 GPIO \u6709\u4ec0\u4e48\u7528&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u901a\u8fc7\u4f4d\u5e26\u522b\u540d\u5730\u5740\u5bf9 ODR\/IDR \u7684\u5355\u4e2a bit \u539f\u5b50\u7f6e\u4f4d\/\u590d\u4f4d&#xff0c;\u4e00\u6761\u603b\u7ebf\u64cd\u4f5c\u5b8c\u6210&#xff0c;\u4e0d\u7528\u5173\u4e2d\u65ad\u3001\u4e0d\u7528 BSRR\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u4f8b&#xff1a;\u628a PA5 \u7f6e\u4f4d \u2192 \u5199\u522b\u540d\u5730\u5740&#xff08;0x4200 0000 \u8d77\u7684\u6620\u5c04\u533a&#xff09;1 \u5b57\u8282 &#061; 1\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8ffd\u95ee&#xff1a;F4 \u652f\u6301\u5417&#xff1f;\u2192 \u652f\u6301&#xff08;Cortex-M3\/M4 \u90fd\u5e26\u4f4d\u5e26\u533a&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">G8. GPIO \u521d\u59cb\u5316\u524d\u4e3a\u4ec0\u4e48\u5fc5\u987b\u5148\u5f00\u65f6\u949f&#xff1f;&#xff08;\u7ed3\u5408 RCC&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">GPIO \u6302\u5728 APB2 \u603b\u7ebf\u4e0a&#xff0c;\u65f6\u949f\u95e8\u63a7\u9ed8\u8ba4\u5173\u95ed&#xff1b;\u4e0d\u5f00\u65f6\u949f\u5219\u5bc4\u5b58\u5668\u5199\u4e0d\u8fdb\u3001\u5f15\u811a\u4e0d\u5de5\u4f5c&#xff0c;\u4e25\u91cd\u65f6\u8bbf\u95ee\u672a\u4f7f\u80fd\u5916\u8bbe\u89e6\u53d1 HardFault\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u987a\u5e8f&#xff1a;\u5f00 GPIO \u65f6\u949f \u2192 \u914d\u6a21\u5f0f\/\u901f\u5ea6\/\u4e0a\u4e0b\u62c9 \u2192 &#xff08;\u8f93\u51fa&#xff09;\u5199\u521d\u503c\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8ffd\u95ee&#xff1a;\u5fd8\u4e86\u5f00\u65f6\u949f\u7684\u8868\u73b0&#xff1f;\u2192 \u7535\u5e73\u65e0\u53d8\u5316\u3001\u8bfb\u503c\u6052 0\/\u6052\u5b9a&#xff0c;\u6392\u67e5\u7b2c\u4e00\u6b65\u5c31\u662f\u67e5 RCC\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">G9. \u6309\u952e\u957f\u6309 \/ \u77ed\u6309 \/ \u53cc\u51fb\u600e\u4e48\u8bc6\u522b&#xff1f;&#xff08;\u72b6\u6001\u673a\u601d\u8def&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u7528\u72b6\u6001\u673a &#043; \u5b9a\u65f6\u5668\u8ba1\u6570&#xff1a;\u7a7a\u95f2 \u2192 \u6309\u4e0b\u6d88\u6296 \u2192 \u6309\u4f4f\u8ba1\u65f6 \u2192 \u91ca\u653e\u5224\u5b9a\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u957f\u6309\u9608\u503c&#xff08;\u5982 1s&#xff09;\u3001\u53cc\u51fb\u7a97\u53e3&#xff08;\u5982 300ms \u5185\u7b2c\u4e8c\u6b21\u6309\u4e0b&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8ffd\u95ee&#xff1a;\u4e3a\u4ec0\u4e48\u7528\u72b6\u6001\u673a\u4e0d\u7528\u591a\u4e2a if&#xff1f;\u2192 \u72b6\u6001\u673a\u628a&#034;\u6296\u52a8\/\u6309\u4e0b\/\u6309\u4f4f\/\u91ca\u653e&#034;\u79bb\u6563\u5316&#xff0c;\u6297\u6296\u3001\u53ef\u6269\u5c55\u3001\u53ef\u590d\u7528&#xff0c;\u662f\u5d4c\u5165\u5f0f\u9762\u8bd5\u52a0\u5206\u70b9\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">G10. \u6309\u952e\u7528\u8f6e\u8be2\u8fd8\u662f\u4e2d\u65ad&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u8f6e\u8be2&#xff1a;\u4e3b\u5faa\u73af\u5468\u671f\u626b\u63cf &#043; \u6d88\u6296&#xff0c;\u7b80\u5355&#xff0c;\u4f46\u5b9e\u65f6\u6027\u5dee\u3001\u53ef\u80fd\u6f0f\u6309\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u4e2d\u65ad&#xff08;EXTI&#xff09;&#xff1a;\u6309\u952e\u6309\u4e0b\u7acb\u5373\u54cd\u5e94&#xff0c;\u4f46\u6296\u52a8\u53ef\u80fd\u89e6\u53d1\u591a\u6b21\u4e2d\u65ad&#xff0c;\u4ecd\u9700\u8f6f\u4ef6\u6d88\u6296&#xff1b;\u4f4e\u529f\u8017\u573a\u666f\u7528\u4e2d\u65ad\u5524\u9192\u66f4\u5408\u9002\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8ffd\u95ee&#xff1a;\u4e2d\u65ad\u91cc\u80fd\u76f4\u63a5\u5904\u7406\u6309\u952e\u4e1a\u52a1\u5417&#xff1f;\u2192 \u4e0d\u884c&#xff0c;\u4e2d\u65ad\u91cc\u53ea\u7f6e\u6807\u5fd7\/\u8ba1\u6570&#xff0c;\u6d88\u6296\u548c\u4e1a\u52a1\u653e\u4e3b\u5faa\u73af\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<h3><span style=\"color:#1a439c\">\u6a21\u5757\u4e8c \u00b7 RCC \u4e0e\u65f6\u949f\u6811&#xff08;6\/6-1&#xff09;R1\u2013R12<\/span><\/h3>\n<p><span style=\"color:#b95514\">R1. \u4e3a\u4ec0\u4e48 STM32 \u8981\u6709\u65f6\u949f\u6811&#xff1f;&#xff08;\u76ee\u7684\u9898&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u4e09\u4e2a\u76ee\u7684&#xff1a;<\/span><span style=\"color:#0d0016\">\u2460 \u5206\u9891\u9002\u914d\u2014\u2014\u5185\u6838\/\u603b\u7ebf\/\u5916\u8bbe\u5404\u81ea\u6709\u4e0d\u540c\u7684\u6700\u9ad8\u9891\u7387&#xff0c;\u7edf\u4e00\u65f6\u949f\u5fc5\u987b\u5206\u9891&#xff1b;\u2461 \u95e8\u63a7\u7701\u7535\u2014\u2014\u4e0d\u7528\u7684\u5916\u8bbe\u5173\u65f6\u949f&#xff0c;\u52a8\u6001\u529f\u8017\u5927\u964d&#xff1b;\u2462 \u7075\u6d3b\u9009\u62e9\u65f6\u949f\u6e90&#xff08;HSI\/HSE\/PLL&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8ffd\u95ee&#xff1a;\u6bcf\u4e2a\u5916\u8bbe\u90fd\u5f00\u7740\u65f6\u949f\u4f1a\u600e\u6837&#xff1f;\u2192 \u529f\u8017\u4e0a\u5347\u3001EMI \u589e\u52a0&#xff0c;\u4e0e\u5916\u8bbe\u529f\u80fd\u65e0\u5173\u4f46\u5f71\u54cd\u7cfb\u7edf\u7a33\u5b9a\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">R2. \u56db\u4e2a\u65f6\u949f\u6e90\u5404\u81ea\u7528\u9014&#xff1f;&#xff08;\u80cc\u8868&#xff09;<\/span><\/p>\n<table>\n<tr><span style=\"color:#0d0016\">\u65f6\u949f\u6e90<\/span><span style=\"color:#0d0016\">\u9891\u7387<\/span><span style=\"color:#0d0016\">\u7528\u9014<\/span><\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#0d0016\">HSI<\/span><\/td>\n<td><span style=\"color:#0d0016\">8MHz RC<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u4e0a\u7535\u9ed8\u8ba4\u3001\u7701\u6676\u632f\u4f4e\u6210\u672c\u65b9\u6848<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">HSE<\/span><\/td>\n<td><span style=\"color:#0d0016\">4~16MHz \u6676\u632f&#xff08;\u5e38\u7528 8M&#xff09;<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u9ad8\u7cbe\u5ea6\u4e3b\u65f6\u949f\u6e90<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">LSI<\/span><\/td>\n<td><span style=\"color:#0d0016\">32kHz RC<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u72ec\u7acb\u770b\u95e8\u72d7 IWDG<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">LSE<\/span><\/td>\n<td><span style=\"color:#0d0016\">32.768kHz \u6676\u632f<\/span><\/td>\n<td><span style=\"color:#0d0016\">RTC \u5b9e\u65f6\u65f6\u949f<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<p><span style=\"color:#b95514\">R3. \u7cfb\u7edf\u65f6\u949f\u600e\u4e48\u4ece 8MHz \u53d8\u5230 72MHz&#xff1f;&#xff08;PLL \u6d41\u7a0b&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">HSE 8MHz \u2192 PLL \u8f93\u5165&#xff08;\u53ef\u9009 \/2&#xff09;\u2192 PLL \u500d\u9891 \u00d79 \u2192 SYSCLK &#061; 72MHz \u2192 AHB \/1 \u2192 APB2 \/1\u3001APB1 \/2\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8ffd\u95ee&#xff1a;\u500d\u9891\u7cfb\u6570\u600e\u4e48\u5b9a&#xff1f;\u2192 \u76ee\u6807 SYSCLK \/ PLL \u8f93\u5165\u9891\u7387&#xff1b;F1 \u4e0a\u9650 72MHz&#xff0c;\u8d85\u9891\u8981\u5c0f\u5fc3\u5916\u8bbe\u4e0a\u9650\u548c Flash \u7b49\u5f85\u5468\u671f\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">R4. APB1 \u548c APB2 \u6709\u4ec0\u4e48\u533a\u522b&#xff1f;\u4e3a\u4ec0\u4e48 APB1 \u8981\u9664 2&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">APB2 \u6700\u9ad8 72MHz&#xff0c;\u6302\u9ad8\u901f\u5916\u8bbe&#xff08;USART1\u3001SPI1\u3001GPIO\u3001ADC\u3001TIM1&#xff09;<\/span><span style=\"color:#0d0016\">&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">APB1 \u6700\u9ad8 36MHz&#xff0c;\u6302\u4f4e\u901f\u5916\u8bbe&#xff08;USART2\/3\u3001I2C\u3001SPI2\u3001TIM2~7\u3001DAC&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u9664 2 \u662f\u4e3a\u4e86\u603b\u7ebf\u529f\u8017\/\u5e26\u5bbd\u5e73\u8861\u2014\u2014\u4f4e\u901f\u5916\u8bbe\u4e0d\u9700\u8981 72MHz&#xff0c;\u8fd8\u80fd\u7701\u7535\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u5916\u8bbe\u6302\u5728\u54ea\u6761\u603b\u7ebf\u662f\u56fa\u5b9a\u7684\u5417&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u662f\u786c\u4ef6\u56fa\u5b9a\u7684&#xff0c;\u67e5\u624b\u518c\u5916\u8bbe\u7ae0\u8282\u7684&#034;bus matrix\/APB&#034;\u5f52\u5c5e&#xff1b;\u9009\u578b\u65f6\u5f71\u54cd\u4f60\u80fd\u8dd1\u591a\u5feb&#xff08;\u5982 APB1 \u7684\u4e32\u53e3\u6ce2\u7279\u7387\u4e0a\u9650\u66f4\u4f4e&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">R5. \u5b9a\u65f6\u5668\u65f6\u949f\u4e3a\u4ec0\u4e48&#034;APB1 \u5206\u9891 \u22601 \u65f6 \u00d72&#034;&#xff1f;&#xff08;\u9ad8\u9891\u9677\u9631&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u5b9a\u65f6\u5668\u9700\u8981\u66f4\u9ad8\u65f6\u949f\u9a71\u52a8\u8ba1\u6570&#xff0c;\u786c\u4ef6\u8bbe\u8ba1&#xff1a;APB1 \u9884\u5206\u9891 &#061;1 \u65f6\u5b9a\u65f6\u5668\u65f6\u949f &#061; APB1&#xff1b;\u9884\u5206\u9891 &gt;1 \u65f6\u81ea\u52a8 \u00d72\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u4f8b&#xff1a;APB1&#061;36MHz \u65f6&#xff0c;TIM2~7 \u7684\u65f6\u949f\u5b9e\u9645\u662f 72MHz\u2014\u2014\u7b97\u5b9a\u65f6\u5668\u6ea2\u51fa\/\u5206\u9891\u5fc5\u987b\u6309 72MHz&#xff0c;\u5426\u5219\u5b9a\u65f6\u65f6\u95f4\u5dee\u4e00\u500d\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8ffd\u95ee&#xff1a;\u8fd9\u4e5f\u662f\u9762\u8bd5\u5e38\u51fa\u7684\u8ba1\u7b97\u9898&#xff1a;APB1&#061;36MHz\u3001TIM3 \u5206\u9891 71\u3001\u91cd\u8f7d 999&#xff0c;\u591a\u4e45\u4e2d\u65ad\u4e00\u6b21&#xff1f;\u2192 72MHz\/(71&#043;1)&#061;1MHz&#xff0c;1MHz \u8ba1\u6570\u5230 1000 \u2192 1ms\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">R6. \u7cfb\u7edf\u65f6\u949f\u914d\u7f6e\u6d41\u7a0b&#xff08;HAL \u7684 SystemClock_Config \u505a\u4e86\u4ec0\u4e48&#xff09;&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u2460 \u5f00\u542f HSE \u2192 \u2461 \u914d\u7f6e Flash \u7b49\u5f85\u5468\u671f&#xff08;72MHz \u9700 2WS&#xff09;\u2192 \u2462 \u914d\u7f6e PLL&#xff08;HSE\/1 \u00d79&#xff09;\u2192 \u2463 \u4f7f\u80fd PLL \u5e76\u7b49\u5c31\u7eea \u2192 \u2464 \u9009\u62e9 PLL \u4f5c SYSCLK \u2192 \u2465 \u914d\u7f6e AHB\/APB1\/APB2 \u9884\u5206\u9891\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8ffd\u95ee&#xff1a;\u987a\u5e8f\u80fd\u4e0d\u80fd\u4e71&#xff1f;\u2192 \u4e0d\u80fd&#xff1a;\u5148\u6709\u7a33\u5b9a\u65f6\u949f\u6e90\u548c Flash \u7b49\u5f85&#xff0c;\u518d\u5207\u9ad8\u901f PLL&#xff0c;\u5426\u5219\u8dd1\u98de\/HardFault\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">R7. \u4e3a\u4ec0\u4e48\u4e32\u53e3\/USB \u5fc5\u987b\u7528 HSE \u800c\u4e0d\u662f HSI&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">HSI \u7cbe\u5ea6\u7ea6 \u00b11%&#xff08;\u6e29\u5ea6\u6f02\u79fb\u66f4\u5927&#xff09;&#xff0c;9600 \u6ce2\u7279\u7387\u8bef\u5dee\u8981\u6c42 &lt;2% \u52c9\u5f3a\u53ef\u7528&#xff0c;\u4f46 USB \u8981\u6c42 0.25% \u4ee5\u5185\u2014\u2014HSI \u5fc5\u7136\u8d85\u5dee \u2192 \u5fc5\u987b HSE \u6676\u632f\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8ffd\u95ee&#xff1a;HSI \u80fd\u6821\u51c6\u5417&#xff1f;\u2192 \u53ef\u4ee5\u8f6f\u4ef6\u5fae\u8c03&#xff08;HSITRIM&#xff09;&#xff0c;\u4f46\u6e29\u5ea6\u6f02\u79fb\u4e0d\u53ef\u63a7&#xff0c;\u91cf\u4ea7\u8fd8\u662f HSE\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">R8. \u5916\u8bbe\u65f6\u949f\u4f7f\u80fd&#xff08;RCC-&gt;APB1ENR\/APB2ENR\/AHBENR&#xff09;\u600e\u4e48\u8bb0&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u4e00\u6761\u603b\u7ebf\u4e00\u4e2a\u4f7f\u80fd\u5bc4\u5b58\u5668&#xff0c;\u6bcf\u4e2a\u5916\u8bbe\u4e00\u4e2a\u4f4d&#xff1a;APB2ENR \u7ba1 USART1\/SPI1\/GPIO\/TIM1\/ADC&#xff0c;APB1ENR \u7ba1 USART2\/3\/I2C\/SPI2\/TIM2~7\/DAC&#xff0c;AHBENR \u7ba1 DMA\/Flash\/SRAM\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8ffd\u95ee&#xff1a;\u65f6\u949f\u4f7f\u80fd\u7684\u610f\u4e49&#xff1f;\u2192 \u95e8\u63a7\u7535\u8def&#xff0c;\u4e0d\u5f00\u65f6\u949f\u5916\u8bbe\u5bc4\u5b58\u5668&#034;\u770b\u4e0d\u89c1&#034;&#xff0c;\u5199\u65e0\u6548\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">R9. \u4ec0\u4e48\u662f\u65f6\u949f\u5b89\u5168\u7cfb\u7edf CSS&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u4f7f\u80fd\u540e&#xff1a;\u82e5 HSE \u5931\u6548&#xff08;\u6676\u632f\u505c\u632f\/\u5f15\u811a\u77ed\u8def&#xff09;&#xff0c;\u81ea\u52a8\u5207\u6362\u56de HSI&#xff0c;\u5e76\u4ea7\u751f NMI \u4e2d\u65ad\u901a\u77e5\u8f6f\u4ef6\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8ffd\u95ee&#xff1a;CSS \u89e6\u53d1\u540e\u7a0b\u5e8f\u4f1a\u600e\u6837&#xff1f;\u2192 \u7cfb\u7edf\u65f6\u949f\u964d\u4e3a HSI 8MHz&#xff0c;\u5916\u8bbe\u9891\u7387\u5168\u53d8&#xff08;\u6ce2\u7279\u7387\u4e71&#xff09;&#xff0c;\u8f6f\u4ef6\u5e94\u5728 NMI \u91cc\u505a\u5b89\u5168\u5904\u7406&#xff08;\u62a5\u8b66\/\u964d\u7ea7&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">R10. \u4f4e\u529f\u8017\u6a21\u5f0f\u4e0b\u65f6\u949f\u884c\u4e3a&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u7761\u7720 Sleep&#xff1a;\u5185\u6838\u65f6\u949f\u505c&#xff0c;\u5916\u8bbe\u65f6\u949f\u7167\u8dd1\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u505c\u673a Stop&#xff1a;\u6240\u6709\u65f6\u949f\u505c&#xff0c;\u9760 EXTI \u7b49\u5916\u90e8\u4e8b\u4ef6\u5524\u9192&#xff0c;\u5524\u9192\u540e\u8981\u91cd\u914d\u65f6\u949f&#xff08;\u5e38\u9700\u91cd\u65b0\u521d\u59cb\u5316 PLL&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u5f85\u673a Standby&#xff1a;\u5168\u90e8\u65ad\u7535&#xff0c;\u53ea\u80fd\u590d\u4f4d\/\u5524\u9192\u5524\u9192\u811a\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u505c\u673a\u6a21\u5f0f\u5524\u9192\u540e\u4e3a\u4ec0\u4e48\u6ce2\u7279\u7387\u4f1a\u4e71&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u5524\u9192\u540e\u65f6\u949f\u6e90\u53ef\u80fd\u56de\u5230\u9ed8\u8ba4\u914d\u7f6e&#xff0c;\u4e32\u53e3\u6309\u65e7\u6ce2\u7279\u7387\u914d\u7f6e\u5bf9\u4e0d\u4e0a&#xff0c;\u9700\u91cd\u65b0\u521d\u59cb\u5316\u65f6\u949f\u548c\u5916\u8bbe\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">R11. MCO \u5f15\u811a\u662f\u5e72\u4ec0\u4e48\u7684&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">MCO \u53ef\u4ee5\u628a\u5185\u90e8\u65f6\u949f\u8f93\u51fa\u5230\u5f15\u811a&#xff0c;\u4f9b\u793a\u6ce2\u5668\u6d4b\u91cf\/\u7ed9\u5916\u90e8\u5668\u4ef6\u4f9b\u65f6\u949f&#xff1b;\u53ef\u8f93\u51fa HSI\/HSE\/PLL\/\u7cfb\u7edf\u65f6\u949f\u5206\u9891\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u8c03\u8bd5\u65f6\u949f\u95ee\u9898\u7b2c\u4e00\u6b65&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u91cf MCO \u8f93\u51fa&#xff0c;\u9a8c\u8bc1 PLL \u662f\u5426\u771f\u7684\u9501\u5230\u76ee\u6807\u9891\u7387\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">R12. \u65f6\u949f\u76f8\u5173\u9762\u8bd5\u8ba1\u7b97\u9898\u6c47\u603b<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u7b97\u6ce2\u7279\u7387&#xff1a;USART1 \u5728 APB2&#061;72MHz\u3001USART2\/3 \u5728 APB1&#061;36MHz&#xff08;\u89c1\u4e32\u53e3\u7bc7 S2&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u7b97\u5b9a\u65f6\u5668\u4e2d\u65ad\u5468\u671f&#xff1a;\u6ce8\u610f \u00d72 \u89c4\u5219\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u7b97 SPI \u6ce2\u7279\u7387&#xff1a;SPI1 \u7528 APB2&#061;72MHz&#xff0c;SPI2 \u7528 APB1&#061;36MHz&#xff0c;\u518d\u9664\u9884\u5206\u9891\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u7b97 ADC \u91c7\u6837\u7387&#xff1a;ADC \u65f6\u949f \u226414MHz&#xff08;APB2 \u518d\u5206\u9891&#xff09;&#xff0c;\u91c7\u6837\u5468\u671f &#043; \u8f6c\u6362\u5468\u671f\u56fa\u5b9a\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<h3><span style=\"color:#1a439c\">\u6a21\u5757\u4e09 \u00b7 USART \u4e32\u53e3&#xff08;\u8bfe\u7a0b\u89d2\u5ea6\u8865\u5145&#xff09;U1\u2013U5<\/span><\/h3>\n<p><span style=\"color:#b95514\">U1. \u8f6e\u8be2\u6a21\u5f0f\u6536\u53d1\u6570\u636e&#xff08;7-1&#xff09;\u5185\u90e8\u673a\u5236&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">HAL_UART_Transmit&#xff1a;\u5199 DR \u2192 \u5fd9\u7b49 TXE \u2192 \u5199\u5b8c\u7b49 TC&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">HAL_UART_Receive&#xff1a;\u5fd9\u7b49 RXNE \u2192 \u8bfb DR\u3002\u5168\u7a0b CPU \u963b\u585e&#xff0c;\u9760\u8d85\u65f6&#xff08;HAL_GetTick&#xff09;\u9632\u5361\u6b7b\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u8f6e\u8be2\u63a5\u6536\u6709\u4ec0\u4e48\u81f4\u547d\u7f3a\u70b9&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u4e3b\u5faa\u73af\u88ab\u5361\u4f4f&#xff0c;\u5176\u4ed6\u4efb\u52a1\u5168\u90e8\u505c\u6446&#xff1b;\u9ad8\u6ce2\u7279\u7387\u4e0b\u6781\u6613 ORE \u4e22\u5b57\u8282\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U2. printf \u91cd\u5b9a\u5411 &#043; \u591a\u6587\u4ef6\u5de5\u7a0b&#xff08;7-2&#xff09;\u600e\u4e48\u7ec4\u7ec7\u4ee3\u7801&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">uart.c\/uart.h \u5c01\u88c5&#xff1a;void UART1_Init(void)\u3001int fputc(int ch, FILE *f)&#xff1b;\u5934\u6587\u4ef6\u653e\u51fd\u6570\u58f0\u660e\u548c extern USART_HandleTypeDef huart1&#xff1b;\u4e3b\u51fd\u6570 include \u5934\u6587\u4ef6\u5373\u53ef\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">extern \u7684\u4f5c\u7528&#xff1a;\u8de8\u6587\u4ef6\u8bbf\u95ee\u5168\u5c40\u53d8\u91cf\u58f0\u660e&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">static&#xff1a;\u6587\u4ef6\u5185\u79c1\u6709\u51fd\u6570\/\u53d8\u91cf\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4e3a\u4ec0\u4e48\u8981\u591a\u6587\u4ef6&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u6a21\u5757\u5316\u3001\u53ef\u590d\u7528\u3001\u7f16\u8bd1\u589e\u91cf\u5feb\u3001\u591a\u4eba\u534f\u4f5c&#xff1b;\u9762\u8bd5\u5e38\u95ee include \u987a\u5e8f\u548c\u5934\u6587\u4ef6\u5b88\u536b&#xff08;#pragma once \/ #ifndef&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U3. \u91cd\u5b9a\u5411\u540e printf \u5e95\u5c42\u600e\u4e48\u5230\u4e32\u53e3\u7684&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">printf \u2192 vsnprintf \u683c\u5f0f\u5316 \u2192 \u9010\u5b57\u7b26\u8c03 fputc \u2192 fputc \u91cc\u7b49 TXE \u5199 DR&#xff08;\u89c1 S10&#xff09;\u3002\u52fe\u9009 MicroLIB \u662f\u4e3a\u4e86\u7981\u7528\u534a\u4e3b\u673a&#xff08;\u5426\u5219 fputc \u91cc\u4f1a\u8c03 ARM \u534a\u4e3b\u673a\u673a\u5236\u5361\u6b7b&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u91cd\u5b9a\u5411\u540e\u8fd8\u80fd\u7528\u4e32\u53e3\u6536\u5417&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u80fd&#xff0c;\u91cd\u5b9a\u5411\u53ea\u6539\u8f93\u51fa\u65b9\u5411&#xff0c;\u63a5\u6536\u4e0d\u53d7\u5f71\u54cd\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U4. \u8f6e\u8be2\/\u4e2d\u65ad\/DMA \u4e09\u6a21\u5f0f\u600e\u4e48\u5728\u5de5\u7a0b\u91cc\u9009&#xff1f;&#xff08;\u8bfe\u7a0b 7-1 vs 10.1 \u5bf9\u6bd4&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u8f6e\u8be2&#xff1a;\u7b80\u5355\u8c03\u8bd5\u3001\u5355\u6b21\u6536\u53d1&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u4e2d\u65ad&#xff1a;\u547d\u4ee4\u4ea4\u4e92\u3001\u4e0d\u963b\u585e\u4e3b\u5faa\u73af&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">DMA&#xff1a;\u5927\u6570\u636e\u5757\u3001\u9ad8\u541e\u5410\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u5de5\u7a0b\u91cc\u901a\u5e38\u600e\u4e48\u642d&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u4e3b\u5faa\u73af\u8f6e\u8be2\u53d1\u9001\u63a7\u5236\u6307\u4ee4&#xff0c;\u4e2d\u65ad\/DMA \u63a5\u6536\u6570\u636e&#xff0c;\u524d\u540e\u53f0\u67b6\u6784\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U5. \u4e32\u53e3\u8c03\u8bd5\u5e38\u9047 3 \u4e2a\u95ee\u9898\u901f\u67e5&#xff08;7-1 \u5b9e\u6218&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u6536\u4e0d\u5230&#xff1a;\u65f6\u949f\/\u5f15\u811a AF \u6ca1\u914d&#xff08;S11&#xff09;&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u4e71\u7801&#xff1a;\u6ce2\u7279\u7387\u6216 APB \u65f6\u949f\u7b97\u9519&#xff08;S2\/S9&#xff09;&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u5361\u6b7b&#xff1a;printf \u534a\u4e3b\u673a\u6ca1\u7981&#xff08;S10&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<h3><span style=\"color:#1a439c\">\u6a21\u5757\u56db \u00b7 I2C&#xff08;8\/8-1\/10.2&#xff09;I1\u2013I12<\/span><\/h3>\n<p><span style=\"color:#b95514\">I1. I2C \u662f\u4ec0\u4e48&#xff1f;\u7269\u7406\u5c42\u7279\u70b9&#xff1f;&#xff08;\u5fc5\u8003&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u4e24\u7ebf&#xff1a;SCL&#xff08;\u65f6\u949f&#xff09;&#043; SDA&#xff08;\u6570\u636e&#xff09;&#xff0c;\u5f00\u6f0f &#043; \u5916\u90e8\u4e0a\u62c9\u7535\u963b&#xff0c;\u534a\u53cc\u5de5&#xff0c;\u652f\u6301\u591a\u4e3b\u673a\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u7279\u70b9&#xff1a;\u5730\u5740\u5bfb\u5740&#xff08;7 \u4f4d\/10 \u4f4d&#xff09;\u3001\u7ebf\u4e0e\u4ef2\u88c1\u3001\u901f\u5ea6\u5206\u6807\u51c6 100k \/ \u5feb\u901f 400k \/ \u5feb\u901f&#043; 1M\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4e3a\u4ec0\u4e48\u5f00\u6f0f&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u624d\u80fd\u7ebf\u4e0e&#xff0c;\u591a\u8bbe\u5907\u5171\u4eab\u603b\u7ebf\u4e0d\u4f1a\u77ed\u8def&#xff1b;\u4e0a\u62c9\u7535\u963b\u8d1f\u8d23\u62c9\u9ad8\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I2. I2C \u7684\u65f6\u5e8f&#xff1a;\u8d77\u59cb\/\u505c\u6b62\/\u6570\u636e\u6709\u6548\u6027\/ACK \u600e\u4e48\u8bf4&#xff1f;&#xff08;\u624b\u6495\u9898&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u8d77\u59cb&#xff1a;SCL \u9ad8\u65f6 SDA \u62c9\u4f4e&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u505c\u6b62&#xff1a;SCL \u9ad8\u65f6 SDA \u62c9\u9ad8\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u6570\u636e\u6709\u6548&#xff1a;SCL \u9ad8\u7535\u5e73\u671f\u95f4 SDA \u5fc5\u987b\u7a33\u5b9a&#xff1b;SCL \u4f4e\u65f6 SDA \u624d\u80fd\u53d8\u5316\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">ACK&#xff1a;\u7b2c 9 \u4e2a\u65f6\u949f&#xff0c;\u63a5\u6536\u65b9\u62c9\u4f4e SDA&#xff1b;\u4e3b\u673a\u6536\u5b8c\u6700\u540e\u5b57\u8282\u53d1 NACK &#043; \u505c\u6b62\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8ffd\u95ee&#xff1a;\u5199\u5168\u8fd9\u56db\u6b65\u662f\u6a21\u62df I2C \u7684\u624b\u6495\u9898&#xff0c;\u9762\u8bd5\u5e38\u8ba9\u5f53\u573a\u5199\u8d77\u59cb\/\u505c\u6b62\/\u53d1\u5b57\u8282\/\u6536\u5b57\u8282\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I3. I2C \u5730\u5740\u673a\u5236&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u7b2c\u4e00\u5b57\u8282 &#061; 7 \u4f4d\u4ece\u673a\u5730\u5740 &#043; 1 \u4f4d R\/W&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u5668\u4ef6\u5730\u5740 &#061; \u82af\u7247\u56fa\u5b9a\u5730\u5740 &#043; \u5f15\u811a\u914d\u7f6e\u4f4d&#xff08;\u5982 A0\/A1\/A2&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u5730\u5740\u51b2\u7a81\u600e\u4e48\u529e&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u5668\u4ef6 A0~A2 \u5f15\u811a\u6539\u63a5&#xff0c;\u6362\u5730\u5740&#xff1b;\u540c\u5730\u5740\u53ea\u80fd\u9519\u5f00\u4f7f\u7528\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I4. \u4e00\u6b21\u5b8c\u6574\u8bfb\/\u5199\u6d41\u7a0b&#xff08;\u4ee5 EEPROM \u4e3a\u4f8b&#xff09;&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u5199&#xff1a;\u8d77\u59cb \u2192 <\/span><span style=\"color:#fe2c24\">\u4ece\u673a\u5730\u5740&#043;W<\/span><span style=\"color:#0d0016\"> \u2192 ACK \u2192 <\/span><span style=\"color:#fe2c24\">\u5bc4\u5b58\u5668\u5730\u5740<\/span><span style=\"color:#0d0016\"> \u2192 ACK \u2192 \u6570\u636e \u2192 ACK \u2192 \u505c\u6b62\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8bfb&#xff1a;\u8d77\u59cb \u2192<\/span><span style=\"color:#fe2c24\"> \u5730\u5740&#043;W <\/span><span style=\"color:#0d0016\">\u2192 ACK \u2192 <\/span><span style=\"color:#fe2c24\">\u5bc4\u5b58\u5668\u5730\u5740<\/span><span style=\"color:#0d0016\"> \u2192 ACK \u2192<\/span><span style=\"color:#fe2c24\"> \u91cd\u590d\u8d77\u59cb <\/span><span style=\"color:#0d0016\">\u2192 <\/span><span style=\"color:#fe2c24\">\u5730\u5740&#043;R <\/span><span style=\"color:#0d0016\">\u2192 ACK \u2192 \u8bfb\u6570\u636e \u2192<\/span><span style=\"color:#fe2c24\"> NACK<\/span><span style=\"color:#0d0016\"> \u2192 \u505c\u6b62\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4e3a\u4ec0\u4e48\u8bfb\u8981&#034;\u91cd\u53d1\u8d77\u59cb&#034;\u800c\u4e0d\u662f\u505c\u6b62\u518d\u5f00\u59cb&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u9632\u6b62\u603b\u7ebf\u88ab\u91ca\u653e\u540e\u5176\u4ed6\u4e3b\u673a\u63d2\u5165&#xff0c;\u4fdd\u8bc1\u672c\u6b21\u64cd\u4f5c\u539f\u5b50\u6027\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I5. \u963b\u585e\u6a21\u5f0f HAL \u6e90\u7801&#xff08;8-1&#xff09;\u5185\u90e8\u662f\u600e\u4e48\u5b9e\u73b0\u7684&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">HAL_I2C_Master_Transmit&#xff1a;\u751f\u6210\u8d77\u59cb \u2192 \u53d1\u5730\u5740 \u2192 \u8f6e\u8be2\/\u4e2d\u65ad\u7b49\u5f85\u5404\u72b6\u6001\u6807\u5fd7&#xff08;TXIS\/BTF\/ADDR&#xff09;\u2192 \u53d1\u6570\u636e \u2192 \u505c\u6b62&#xff1b;\u6bcf\u6b65\u5e26 HAL_GetTick \u8d85\u65f6&#xff0c;\u8d85\u65f6\u8fd4\u56de HAL_TIMEOUT\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;HAL \u963b\u585e\u6a21\u5f0f\u771f\u7684\u662f\u7eaf\u8f6e\u8be2\u5417&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u5185\u90e8\u662f&#034;\u4e2d\u65ad\u72b6\u6001\u673a &#043; \u8d85\u65f6\u8f6e\u8be2&#034;&#xff0c;\u5de5\u7a0b\u4e0a\u53eb\u963b\u585e\u5f0f\u8c03\u7528&#xff0c;ISR \u91cc\u8fd8\u5728\u63a8\u8fdb\u72b6\u6001\u673a\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I6. I2C \u603b\u7ebf\u5361\u6b7b&#xff08;SDA \u4e00\u76f4\u88ab\u62c9\u4f4e&#xff09;\u600e\u4e48\u6062\u590d&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u539f\u56e0&#xff1a;\u4ece\u673a\u5f02\u5e38\u3001\u4e3b\u673a\u65f6\u5e8f\u9519\u3001\u4e0a\u7535\u65f6\u5e8f\u3001\u5f15\u811a\u88ab\u5916\u90e8\u62c9\u6b7b\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u6062\u590d\u624b\u6bb5&#xff1a;\u4e3b\u673a\u53d1 9~16 \u4e2a SCL \u65f6\u949f\u8109\u51b2&#xff0c;\u8ba9\u5361\u4f4f\u7684\u4ece\u673a\u91ca\u653e SDA&#xff1b;<\/span><span style=\"color:#0d0016\">\u518d\u53d1\u505c\u6b62&#xff1b;\u4e25\u91cd\u65f6\u65ad\u7535\u91cd\u542f\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u8f6f\u4ef6\u4e0a\u600e\u4e48\u9884\u9632&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u4e0a\u7535\u7b49\u4ece\u673a\u5c31\u7eea\u3001\u8f6f\u4ef6\u91cd\u8bd5\u3001\u9519\u8bef\u540e\u91cd\u65b0\u521d\u59cb\u5316\u5916\u8bbe\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I7. \u6536\u5230 NACK&#xff08;\u65e0\u5e94\u7b54&#xff09;\u600e\u4e48\u6392\u67e5&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u987a\u5e8f&#xff1a;\u5730\u5740\u5bf9\u4e0d\u5bf9&#xff08;\u5668\u4ef6\u624b\u518c&#xff09;\u2192 \u5668\u4ef6\u4e0a\u7535\u6ca1&#xff08;\u91cf VCC&#xff09;\u2192 \u4e0a\u62c9\u7535\u963b\u6709\u6ca1\u6709&#xff08;SDA \u7a7a\u95f2\u662f\u5426\u9ad8&#xff09;\u2192 SCL\/SDA \u6709\u6ca1\u6709\u63a5\u53cd \u2192 \u4ece\u673a\u662f\u5426\u88ab\u5360\u7528\/\u5361\u6b7b\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4e3b\u673a\u8bfb\u6700\u540e\u4e00\u4e2a\u5b57\u8282\u4e3a\u4ec0\u4e48\u8981\u53d1 NACK&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u544a\u8bc9\u4ece\u673a&#034;\u4e0d\u518d\u8981\u4e86&#034;&#xff0c;\u4ece\u673a\u91ca\u653e\u603b\u7ebf&#xff0c;\u63a5\u7740\u53d1\u505c\u6b62\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I8. \u4e0a\u62c9\u7535\u963b\u600e\u4e48\u53d6\u503c&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u6298\u4e2d\u901f\u5ea6\u4e0e\u529f\u8017&#xff1a;\u7535\u963b\u5c0f \u2192 \u4e0a\u5347\u6cbf\u5feb&#xff08;\u53ef\u8dd1\u9ad8\u901f&#xff09;\u4f46\u529f\u8017\u5927&#xff1b;\u7535\u963b\u5927 \u2192 \u7701\u7535\u4f46\u8fb9\u6cbf\u6162\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u5e38\u7528&#xff1a;100kHz \u7528 4.7k10k&#xff0c;400kHz \u7528 2.2k4.7k&#xff08;3.3V \u4e0b&#xff09;&#xff1b;\u5668\u4ef6\u591a\/\u5bb9\u6027\u5927\u8981\u66f4\u5c0f\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u6f0f\u9009\u4e0a\u62c9\u4f1a\u600e\u6837&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 SDA \u7a7a\u95f2\u7535\u5e73\u4e0d\u786e\u5b9a&#xff0c;\u901a\u4fe1\u5b8c\u5168\u5931\u8d25\u6216\u65f6\u597d\u65f6\u574f\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I9. \u786c\u4ef6 I2C vs \u6a21\u62df I2C&#xff08;IO \u53e3\u6a21\u62df&#xff09;\u600e\u4e48\u9009&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u6a21\u62df&#xff1a;\u4efb\u610f\u5f15\u811a\u3001\u65f6\u5e8f\u81ea\u5df1\u63a7\u3001\u4e0d\u53d7\u786c\u4ef6 BUG \u5f71\u54cd&#xff1b;\u4ee3\u4ef7\u662f\u5360 CPU\u3001\u4ee3\u7801\u591a\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u786c\u4ef6&#xff1a;\u5916\u8bbe\u81ea\u52a8\u4ea7\u751f\u65f6\u5e8f\u3001\u53ef\u914d DMA\/\u4e2d\u65ad\u3001\u7701 CPU&#xff1b;\u4f46 F1 \u8001\u578b\u53f7\u786c\u4ef6 I2C \u6709\u5df2\u77e5 errata&#xff08;\u603b\u7ebf\u9519\u8bef\u3001\u5361\u6b7b&#xff09;&#xff0c;\u5f88\u591a\u6559\u7a0b\u5b81\u53ef\u7528\u6a21\u62df\u2014\u2014\u9762\u8bd5\u53ef\u4ee5\u63d0\u8fd9\u70b9&#xff0c;\u5c55\u793a\u770b\u8fc7\u52d8\u8bef\u624b\u518c\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;F4 \u4e4b\u540e\u786c\u4ef6 I2C \u7a33\u5b9a\u5417&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u57fa\u672c\u7a33\u5b9a&#xff0c;\u5de5\u7a0b\u4e0a\u786c\u4ef6 I2C &#043; \u4e2d\u65ad\/DMA \u662f\u4e3b\u6d41\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I10. I2C \u4e2d\u65ad\u6a21\u5f0f\u6536\u53d1&#xff08;10.2&#xff09;\u7684\u4e8b\u4ef6\u4e2d\u65ad\u6709\u54ea\u4e9b&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u4e8b\u4ef6\u4e2d\u65ad EV&#xff08;TXE\/RXNE\/ADDR\/STOPF\/BTF&#xff09;&#043; \u9519\u8bef\u4e2d\u65ad ERR&#xff08;BERR\/ARLO\/AF\/OVR&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">HAL \u56de\u8c03&#xff1a;HAL_I2C_MasterRxCpltCallback \/ MasterTxCpltCallback \/ ErrorCallback&#xff1b;\u4e2d\u65ad\u6a21\u5f0f\u4e0d\u963b\u585e\u4e3b\u5faa\u73af&#xff0c;\u914d\u5408\u72b6\u6001\u673a\u63a8\u8fdb\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4e2d\u65ad\u6a21\u5f0f\u6bd4\u963b\u585e\u597d\u5728\u54ea&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u4e3b\u5faa\u73af\u4e0d\u88ab I2C \u7b49\u5f85\u5361\u4f4f&#xff0c;\u53ef\u540c\u65f6\u5904\u7406\u4e32\u53e3\/\u6309\u952e\/\u5b9a\u65f6\u5668&#xff1b;\u4ee3\u4ef7\u662f\u72b6\u6001\u673a\u590d\u6742\u5ea6\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I11. \u591a\u4e2a I2C \u4ece\u673a\u6302\u4e00\u6761\u603b\u7ebf&#xff0c;\u600e\u4e48\u4e92\u4e0d\u5e72\u6270&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u9760\u5730\u5740\u533a\u5206&#xff1a;\u6bcf\u6b21\u901a\u4fe1\u5148\u53d1\u5730\u5740&#xff0c;\u53ea\u6709\u5730\u5740\u5339\u914d\u7684\u4ece\u673a\u5e94\u7b54&#xff1b;\u4ece\u673a\u4e0d\u5339\u914d\u65f6\u4fdd\u6301\u9ad8\u963b\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u5982\u679c\u4e24\u4e2a\u4ece\u673a\u5730\u5740\u76f8\u540c&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u51b2\u7a81&#xff0c;\u53ea\u80fd\u6362\u5730\u5740\u5f15\u811a\u6216\u5206\u603b\u7ebf\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I12. I2C \u9762\u8bd5\u624b\u6495\u9898&#xff1a;\u5199\u6a21\u62df I2C \u8d77\u59cb\u6761\u4ef6&#xff08;\u5fc5\u80cc&#xff09;<\/span><\/p>\n<p>void I2C_Start(void) {<br \/>\n    SDA_H();  SCL_H();               \/\/ \u7a7a\u95f2&#xff1a;\u90fd\u9ad8<br \/>\n    delay();  SDA_L();               \/\/ SCL \u9ad8\u65f6 SDA \u62c9\u4f4e &#061; \u8d77\u59cb<br \/>\n    delay();  SCL_L();               \/\/ \u8fdb\u5165\u4f20\u8f93<br \/>\n}<\/p>\n<ul>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u505c\u6b62\u6761\u4ef6&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 SCL \u4f4e\u65f6 SDA \u62c9\u4f4e \u2192 SCL \u62c9\u9ad8 \u2192 SDA \u62c9\u9ad8&#xff08;SCL \u9ad8\u65f6 SDA \u4e0a\u5347\u6cbf&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<h3><span style=\"color:#1a439c\">\u6a21\u5757\u4e94 \u00b7 SPI&#xff08;9\/9-1\/9-2\/10.3&#xff09;P1\u2013P12<\/span><\/h3>\n<p><span style=\"color:#b95514\">P1. SPI \u56db\u6839\u7ebf\u5206\u522b\u5e72\u4ec0\u4e48&#xff1f;&#xff08;\u5fc5\u8003&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">SCK \u65f6\u949f&#xff08;\u4e3b\u673a\u4ea7\u751f&#xff09;\u3001MOSI \u4e3b\u673a\u51fa\u4ece\u673a\u5165\u3001<\/span><\/li>\n<li><span style=\"color:#0d0016\">MISO \u4ece\u673a\u51fa\u4e3b\u673a\u5165\u3001CS\/NSS \u7247\u9009&#xff08;\u4f4e\u6709\u6548&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u5168\u53cc\u5de5\u3001\u540c\u6b65&#xff08;\u65f6\u949f\u7531\u4e3b\u673a\u7ed9&#xff09;\u3001\u4e00\u4e3b\u591a\u4ece\u9760 CS \u533a\u5206\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;SPI \u9700\u8981\u4e0a\u62c9\u7535\u963b\u5417&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u4e0d\u9700\u8981&#xff08;\u63a8\u633d\u9a71\u52a8&#xff09;&#xff0c;\u8fd9\u662f\u4e0e I2C \u6700\u5927\u7684\u7269\u7406\u5c42\u533a\u522b\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P2. SPI \u56db\u79cd\u6a21\u5f0f&#xff08;CPOL\/CPHA&#xff09;\u600e\u4e48\u7406\u89e3&#xff1f;Flash \u5e38\u7528\u54ea\u4e2a&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">CPOL&#xff1a;\u7a7a\u95f2\u65f6\u65f6\u949f\u7535\u5e73&#xff08;0&#061;\u4f4e&#xff0c;1&#061;\u9ad8&#xff09;&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">CPHA&#xff1a;\u91c7\u6837\u6cbf&#xff08;0&#061;\u7b2c\u4e00\u4e2a\u6cbf&#xff0c;1&#061;\u7b2c\u4e8c\u4e2a\u6cbf&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u6a21\u5f0f 0&#xff1a;CPOL&#061;0,CPHA&#061;0&#xff08;\u7a7a\u95f2\u4f4e\u3001\u4e0a\u5347\u6cbf\u91c7\u6837&#xff09;&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u6a21\u5f0f 3&#xff1a;CPOL&#061;1,CPHA&#061;1&#xff08;\u7a7a\u95f2\u9ad8\u3001\u4e0a\u5347\u6cbf\u91c7\u6837&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">Flash&#xff08;W25Q \u7b49&#xff09;\u5e38\u7528 MODE 0 \/ MODE 3&#xff0c;\u4e24\u8005\u7a7a\u95f2\u7535\u5e73\u76f8\u53cd\u4f46\u76f8\u4f4d\u76f8\u540c&#xff0c;\u90fd\u517c\u5bb9\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u6a21\u5f0f\u4e0d\u5339\u914d\u4f1a\u600e\u6837&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u4e3b\u673a\u91c7\u6837\u70b9\u548c\u4ece\u673a\u6570\u636e\u8f93\u51fa\u65f6\u523b\u5bf9\u4e0d\u4e0a&#xff0c;\u6536\u5230\u4e71\u7801\/0xFF\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P3. \u5168\u53cc\u5de5\u610f\u5473\u7740\u4ec0\u4e48&#xff1f;\u4e3a\u4ec0\u4e48\u53d1\u9001\u6570\u636e\u65f6\u540c\u65f6\u4f1a\u6536\u5230\u6570\u636e&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u79fb\u4f4d\u5bc4\u5b58\u5668\u4e00\u4e2a\u65f6\u949f\u79fb\u51fa 1 bit\u3001\u79fb\u5165 1 bit \u2192 \u53d1\u4e00\u5b57\u8282\u7684\u540c\u65f6\u6536\u4e00\u5b57\u8282\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u7ecf\u5178\u6280\u5de7&#xff1a;<\/span><span style=\"color:#1c7331\">\u60f3\u8bfb\u4ece\u673a\u6570\u636e&#xff0c;\u4e3b\u673a\u53d1 0xFF&#xff08;\u54d1\u5b57\u8282&#xff09; \u63a8\u65f6\u949f<\/span><span style=\"color:#0d0016\">\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u8fd9\u4e2a\u7279\u6027\u5e26\u6765\u4ec0\u4e48\u5751&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u53ea\u53d1\u4e0d\u6536\u4e5f\u8981\u5904\u7406 RXNE\/\u8bfb DR&#xff0c;\u5426\u5219 FIFO \u6ea2\u51fa\u4e22\u6570\u636e\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P4. CS \u7247\u9009\u7684\u4f5c\u7528&#xff1f;\u591a\u4ece\u673a\u600e\u4e48\u6302&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">CS \u62c9\u4f4e\u9009\u4e2d\u4ece\u673a&#xff1b;\u591a\u4ece\u673a\u5404\u63a5\u4e00\u6839 CS&#xff08;\u4e3b\u673a\u591a\u5f15\u811a&#xff09;&#xff0c;SCK\/MOSI\/MISO \u5171\u4eab\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;CS \u65f6\u5e8f\u6ce8\u610f\u4ec0\u4e48&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u5148\u62c9\u4f4e CS \u518d\u53d1\u6570\u636e&#xff0c;\u53d1\u5b8c\u7b49 BSY\/TXE \u6e05\u518d\u62c9\u9ad8 CS&#xff0c;\u5426\u5219\u6570\u636e\u6b8b\u7f3a&#xff1b;Flash \u64cd\u4f5c\u671f\u95f4 CS \u4e0d\u80fd\u4e71\u52a8\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P5. \u963b\u585e\u5f0f\u901a\u4fe1 HAL \u6e90\u7801&#xff08;9-1&#xff09;\u5185\u90e8\u6d41\u7a0b&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">HAL_SPI_TransmitReceive&#xff1a;\u5f00 SPI \u2192 \u5faa\u73af&#xff1a;\u5199 DR&#xff08;\u53d1&#xff09;\u2192 \u7b49 RXNE&#xff08;\u6536&#xff09;\u2192 \u8bfb\u5b8c\u6240\u6709\u5b57\u8282 \u2192 \u7b49 BSY \u6e05&#xff08;\u79fb\u4f4d\u5bc4\u5b58\u5668\u53d1\u5b8c&#xff09;\u2192 \u8fd4\u56de\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4e3a\u4ec0\u4e48\u6700\u540e\u8981\u7b49 BSY&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 BSY&#061;1 \u8868\u793a\u8fd8\u5728\u79fb\u51fa\u6700\u540e\u4e00\u4f4d&#xff0c;\u4e0d\u7b49\u5c31\u5173 SPI\/\u62c9\u9ad8 CS \u4f1a\u4e22\u5c3e\u5b57\u8282&#xff08;\u540c\u4e32\u53e3 TC \u7684\u9053\u7406&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P6. SPI Flash \u9a71\u52a8\u5f00\u53d1&#xff08;9-2&#xff09;\u5fc5\u80cc\u547d\u4ee4\u4e0e\u6d41\u7a0b<\/span><\/p>\n<table>\n<tr><span style=\"color:#0d0016\">\u64cd\u4f5c<\/span><span style=\"color:#0d0016\">\u547d\u4ee4\u7801<\/span><span style=\"color:#0d0016\">\u8bf4\u660e<\/span><\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#0d0016\">\u8bfb ID<\/span><\/td>\n<td><span style=\"color:#0d0016\">0x9F<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u8fd4\u56de 3~4 \u5b57\u8282 JEDEC ID&#xff08;\u8bc6\u522b\u82af\u7247&#xff09;<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u5199\u4f7f\u80fd<\/span><\/td>\n<td><span style=\"color:#0d0016\">0x06<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u7f6e WEL \u4f4d&#xff0c;\u5199\/\u64e6\u9664\u524d\u5fc5\u987b\u53d1<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u8bfb\u72b6\u6001\u5bc4\u5b58\u5668<\/span><\/td>\n<td><span style=\"color:#0d0016\">0x05<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u67e5 WIP \u5fd9\u6807\u5fd7&#xff0c;\u5fd9\u65f6\u8f6e\u8be2\u7b49<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u8bfb\u6570\u636e<\/span><\/td>\n<td><span style=\"color:#0d0016\">0x03<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u4efb\u610f\u5730\u5740\u8fde\u7eed\u8bfb<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u9875\u7f16\u7a0b<\/span><\/td>\n<td><span style=\"color:#0d0016\">0x02<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u4e00\u9875\u6700\u591a 256 \u5b57\u8282&#xff0c;\u8de8\u9875\u8981\u62c6<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u6247\u533a\u64e6\u9664<\/span><\/td>\n<td><span style=\"color:#0d0016\">0x20<\/span><\/td>\n<td><span style=\"color:#0d0016\">4KB \u7c92\u5ea6&#xff1b;\u5199\u524d\u5fc5\u987b\u5148\u64e6\u9664<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee 1&#xff1a;\u4e3a\u4ec0\u4e48\u5199\u4e4b\u524d\u5fc5\u987b\u5148\u64e6\u9664&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 Flash \u7f16\u7a0b\u53ea\u80fd\u628a\u4f4d\u4ece 1\u21920&#xff0c;\u64e6\u9664\u628a\u6240\u6709\u4f4d\u6062\u590d\u4e3a 1&#xff0c;\u624d\u80fd\u518d\u7f16\u7a0b\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee 2&#xff1a;\u8de8\u9875\u5199\u6570\u636e\u4f1a\u600e\u6837&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u5730\u5740\u56de\u7ed5\u5230\u9875\u9996\u8986\u76d6\u65e7\u6570\u636e&#xff0c;\u5fc5\u987b\u6309\u9875\u5207\u5206\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P7. Flash \u9a71\u52a8\u5f00\u53d1\u7684\u72b6\u6001\u673a\/\u6d41\u7a0b&#xff08;\u9762\u8bd5\u600e\u4e48\u8bb2&#xff09;&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u5b8c\u6574\u94fe\u8def&#xff1a;\u4e0a\u7535\u8bfb ID \u6821\u9a8c \u2192 \u5199\u4f7f\u80fd \u2192 \u64e6\u9664&#xff08;\u8f6e\u8be2 WIP&#xff09;\u2192 \u5199\u4f7f\u80fd \u2192 \u9875\u7f16\u7a0b&#xff08;\u8f6e\u8be2 WIP&#xff09;\u2192 \u8bfb\u56de\u6821\u9a8c\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u64e6\u9664\/\u7f16\u7a0b\u5931\u8d25\u600e\u4e48\u5904\u7406&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u91cd\u8bd5\u6709\u9650\u6b21\u3001\u62a5\u9519\u3001\u6389\u7535\u4fdd\u62a4&#xff08;\u5148\u64e6\u540e\u5199\u7684\u6389\u7535\u7a97\u53e3\u662f\u7ecf\u5178\u53ef\u9760\u6027\u95ee\u9898&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P8. SPI vs I2C \u5bf9\u6bd4&#xff08;\u5fc5\u80cc\u8868&#xff09;<\/span><\/p>\n<table>\n<tr><span style=\"color:#0d0016\">\u7ef4\u5ea6<\/span><span style=\"color:#0d0016\">SPI<\/span><span style=\"color:#0d0016\">I2C<\/span><\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#0d0016\">\u7ebf\u6570<\/span><\/td>\n<td><span style=\"color:#0d0016\">4&#xff08;\u542b CS&#xff09;<\/span><\/td>\n<td><span style=\"color:#0d0016\">2<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u53cc\u5de5<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u5168\u53cc\u5de5<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u534a\u53cc\u5de5<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u901f\u7387<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u53ef\u8fbe\u6570\u5341 MHz<\/span><\/td>\n<td><span style=\"color:#0d0016\">100k~1M<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u5bfb\u5740<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u7247\u9009 CS<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u5730\u5740\u5e27<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u591a\u4e3b\u673a<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u4e0d\u652f\u6301<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u652f\u6301&#xff08;\u4ef2\u88c1&#xff09;<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u9a71\u52a8<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u63a8\u633d&#xff0c;\u65e0\u4e0a\u62c9<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u5f00\u6f0f &#043; \u4e0a\u62c9<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u5178\u578b\u5668\u4ef6<\/span><\/td>\n<td><span style=\"color:#0d0016\">Flash\u3001SD\u3001\u5c4f\u3001ADC<\/span><\/td>\n<td><span style=\"color:#0d0016\">EEPROM\u3001\u4f20\u611f\u5668\u3001RTC<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li><span style=\"color:#fe2c24\">\u4ec0\u4e48\u65f6\u5019\u9009 SPI&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u9ad8\u901f\u3001\u5927\u6570\u636e&#xff08;Flash\u3001\u5c4f&#xff09;&#xff1b;<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u4ec0\u4e48\u65f6\u5019 I2C&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u5f15\u811a\u5c11\u3001\u4f4e\u901f\u3001\u591a\u8bbe\u5907\u603b\u7ebf&#xff08;\u4f20\u611f\u5668\u96c6\u7fa4&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P9. SPI \u4e2d\u65ad\u6a21\u5f0f\u6536\u53d1&#xff08;10.3&#xff09;\u548c DMA \u600e\u4e48\u7ed3\u5408&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u4e2d\u65ad&#xff1a;TXE \u7a7a\u8fdb\u4e2d\u65ad\u53d1\u4e0b\u4e00\u4e2a\u5b57\u8282\u3001RXNE \u6ee1\u8fdb\u4e2d\u65ad\u6536\u5b57\u8282\u2014\u2014\u6bcf\u5b57\u8282\u4e00\u6b21\u4e2d\u65ad&#xff0c;\u9002\u5408\u4e2d\u91cf\u6570\u636e\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u5927\u5757\u6570\u636e\u7528 DMA&#xff1a;\u5185\u5b58\u2194SPI_DR \u786c\u4ef6\u642c\u79fb&#xff0c;\u4f20\u8f93\u5b8c\u6210\u4e2d\u65ad\u6536\u5c3e&#xff08;\u53c2\u8003\u4e32\u53e3 DMA \u601d\u8def&#xff0c;S13&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;SPI \u6536 DMA \u548c\u53d1 DMA \u53ef\u4ee5\u540c\u65f6\u5f00\u5417&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u53ef\u4ee5&#xff0c;SPI \u5168\u53cc\u5de5\u5929\u7136\u652f\u6301\u53cc\u901a\u9053 DMA\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P10. SPI \u6536\u4e71\u7801\u5e38\u89c1\u539f\u56e0\u6392\u67e5&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u987a\u5e8f&#xff1a;CPOL\/CPHA \u6a21\u5f0f\u5339\u914d \u2192 MISO\/MOSI \u662f\u5426\u63a5\u53cd \u2192 CS \u65f6\u5e8f&#xff08;\u8fc7\u65e9\/\u8fc7\u665a\u62c9\u9ad8&#xff09;\u2192 \u65f6\u949f\u9891\u7387\u592a\u9ad8&#xff08;\u4ece\u673a\u4e0a\u9650&#xff09;\u2192 \u4e0a\u62c9\/\u8d70\u7ebf\u5e72\u6270\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u6536 0xFF \u7279\u6307\u4ec0\u4e48&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u4ece\u673a\u6ca1\u88ab\u6b63\u786e\u9009\u4e2d&#xff08;CS \u95ee\u9898&#xff09;\u6216 MISO \u6ca1\u63a5\/\u60ac\u7a7a\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P11. SPI \u65f6\u949f\u9891\u7387\u80fd\u968f\u4fbf\u8bbe\u5417&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u4e0a\u9650\u53d7\u4ece\u673a\u6570\u636e\u624b\u518c\u7ea6\u675f&#xff08;W25Q \u4e00\u822c\u652f\u6301 100MHz&#043;&#xff0c;\u4f46\u677f\u7ea7\u8d70\u7ebf\/\u4e3b\u673a\u5916\u8bbe\u4e0a\u9650\u5148\u5230&#xff09;&#xff1b;F1 SPI1 \u7531 APB2&#061;72MHz \u5206\u9891\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u9ad8\u901f SPI \u8981\u6ce8\u610f\u4ec0\u4e48&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u8d70\u7ebf\u77ed\u3001\u963b\u6297\u4e00\u81f4\u3001\u5fc5\u8981\u65f6\u964d\u4f4e\u901f\u7387\u6362\u7a33\u5b9a\u6027\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P12. SPI \u624b\u6495\u9898&#xff1a;\u5199 SPI \u4e3b\u673a\u6536\u53d1\u4e00\u5b57\u8282&#xff08;\u5bc4\u5b58\u5668\u98ce\u683c&#xff09;<\/span><\/p>\n<p>uint8_t SPI_SendByte(uint8_t byte) {<br \/>\n    SPI1-&gt;DR &#061; byte;                          \/\/ \u53d1\u4e00\u4e2a\u5b57\u8282<br \/>\n    while (!(SPI1-&gt;SR &amp; SPI_SR_RXNE));        \/\/ \u7b49\u6536\u5230&#xff08;\u5168\u53cc\u5de5\u5fc5\u6709\u56de\u5e94&#xff09;<br \/>\n    return SPI1-&gt;DR;                          \/\/ \u8bfb\u56de\u4ece\u673a\u6570\u636e<br \/>\n}<\/p>\n<ul>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4e3a\u4ec0\u4e48\u53d1\u4e00\u5b57\u8282\u540e\u4e00\u5b9a\u80fd\u7b49\u5230 RXNE&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u5168\u53cc\u5de5&#xff1a;\u53d1 8 bit \u7684\u540c\u65f6\u6536\u5230 8 bit&#xff0c;DR \u5fc5\u586b\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<h3><span style=\"color:#1a439c\">\u6a21\u5757\u516d \u00b7 \u4e2d\u65ad\u4e0e\u5f02\u5e38&#xff08;10\/10.1~10.4&#xff09;E1\u2013E10<\/span><\/h3>\n<p><span style=\"color:#b95514\">E1. \u5f31\u5f15\u7528 __weak \/ WEAK \u662f\u4ec0\u4e48&#xff1f;\u6709\u4ec0\u4e48\u4f5c\u7528&#xff1f;&#xff08;10.4 \u5fc5\u8003&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u94fe\u63a5\u5668\u7b26\u53f7\u5f31\u5b9a\u4e49&#xff1a;\u7528\u6237\u5b9a\u4e49\u540c\u540d\u5f3a\u7b26\u53f7\u65f6&#xff0c;\u8986\u76d6\u5f31\u7b26\u53f7&#xff1b;\u6ca1\u6709\u5f3a\u7b26\u53f7\u5219\u7528\u5f31\u5b9e\u73b0\u515c\u5e95\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u5178\u578b&#xff1a;HAL \u5e93\u6240\u6709\u56de\u8c03\u90fd\u662f __weak \u9ed8\u8ba4\u7a7a\u5b9e\u73b0&#xff08;HAL_UART_RxCpltCallback \u7b49&#xff09;&#xff0c;\u7528\u6237\u5728\u4efb\u610f\u6e90\u6587\u4ef6\u5199\u540c\u540d\u51fd\u6570\u5373\u53ef\u751f\u6548&#xff0c;\u65e0\u9700\u6539\u5e93\u6e90\u7801\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee 1&#xff1a;\u4e24\u4e2a\u6587\u4ef6\u90fd\u5b9a\u4e49\u4e86\u540c\u540d\u5f3a\u7b26\u53f7\u4f1a\u600e\u6837&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u94fe\u63a5\u9519\u8bef&#xff08;\u91cd\u590d\u5b9a\u4e49&#xff09;&#xff1b;weak \u5c31\u4e0d\u4f1a\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee 2&#xff1a;\u4e3a\u4ec0\u4e48\u4e0d\u76f4\u63a5\u7ed9\u56de\u8c03\u5199\u6b7b\u5b9e\u73b0&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u5e93\u4e0e\u7528\u6237\u4ee3\u7801\u89e3\u8026&#xff0c;\u7528\u6237\u60f3\u7528\u5c31\u91cd\u5199\u3001\u4e0d\u60f3\u7528\u5c31\u7559\u7a7a&#xff0c;HAL \u53ef\u79fb\u690d\u6027\u6765\u6e90\u4e4b\u4e00\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee 3&#xff1a;\u81ea\u5df1\u9879\u76ee\u91cc\u80fd\u7528\u5417&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u80fd&#xff0c;\u5199\u9a71\u52a8\u9ed8\u8ba4\u5904\u7406 &#043; \u8ba9\u5e94\u7528\u5c42\u53ef\u8986\u76d6&#xff08;\u56de\u8c03\u6a21\u5f0f&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">E2. \u4e2d\u65ad\u6a21\u5f0f\u6536\u53d1 vs \u963b\u585e\u6a21\u5f0f\u6536\u53d1&#xff0c;\u672c\u8d28\u533a\u522b&#xff1f;&#xff08;10.1 vs 7-1&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u963b\u585e&#xff1a;\u8c03\u7528\u7ebf\u7a0b\/\u4e3b\u5faa\u73af\u4e00\u76f4\u7b49\u5230\u6536\u53d1\u5b8c\u624d\u8fd4\u56de&#xff0c;\u671f\u95f4\u5565\u4e5f\u5e72\u4e0d\u4e86\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u4e2d\u65ad&#xff1a;\u53d1\u8d77\u540e\u7acb\u5373\u8fd4\u56de&#xff0c;\u5b57\u8282\u5230\u4e86 ISR \u5904\u7406\/\u7f6e\u6807\u5fd7&#xff0c;\u4e3b\u5faa\u73af\u7ee7\u7eed\u8dd1\u2014\u2014\u524d\u540e\u53f0\u67b6\u6784\u7684\u6838\u5fc3\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4e2d\u65ad\u6a21\u5f0f\u4f1a\u4e0d\u4f1a\u6f0f\u6570\u636e&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u4f1a&#xff0c;ISR \u5fc5\u987b\u53ca\u65f6&#xff0c;\u4e14\u63a5\u6536\u7f13\u51b2\/\u5904\u7406\u8981\u8ddf\u4e0a&#xff1b;\u9ad8\u8d1f\u8f7d\u65f6\u6539\u7528 DMA\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">E3. \u4e3a\u4ec0\u4e48&#034;\u4e2d\u65ad &#043; \u4e3b\u5faa\u73af&#034;\u53eb\u524d\u540e\u53f0\u67b6\u6784&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u524d\u53f0 &#061; \u4e2d\u65ad&#xff08;\u7a81\u53d1\u4e8b\u4ef6\u7acb\u5373\u54cd\u5e94&#xff09;&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u540e\u53f0 &#061; \u4e3b\u5faa\u73af&#xff08;\u8f6e\u8be2\u5904\u7406\u7d2f\u79ef\u4efb\u52a1&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u4e24\u8005\u901a\u8fc7\u6807\u5fd7\u4f4d\/\u961f\u5217\u901a\u4fe1\u3002<\/span><\/li>\n<li><span style=\"color:#be191c\">\u8ffd\u95ee&#xff1a;\u8fd9\u5957\u67b6\u6784\u7684\u74f6\u9888&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u540e\u53f0\u4efb\u52a1\u591a\u65f6\u8f6e\u8be2\u5468\u671f\u53d8\u957f&#xff0c;\u5b9e\u65f6\u6027\u5dee \u2192 \u624d\u9700\u8981 RTOS\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">E4. USART \u4e2d\u65ad\u6a21\u5f0f&#xff08;10.1&#xff09;\u4e2d\u65ad\u91cc\u8be5\u505a\u4ec0\u4e48&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u6536&#xff1a;\u8bfb SR \u5224\u65ad RXNE \u2192 \u8bfb DR \u5b58\u7f13\u51b2\/\u73af\u5f62\u961f\u5217 \u2192 \u6e05\u6807\u5fd7&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u53d1&#xff1a;TXE \u7a7a \u2192 \u5199 DR \u53d1\u4e0b\u4e00\u5b57\u8282&#xff0c;\u53d1\u5b8c\u7b49 TC\u3002<\/span><\/li>\n<li><span style=\"color:#be191c\">\u8ffd\u95ee&#xff1a;\u4e2d\u65ad\u548c\u4e3b\u5faa\u73af\u4e4b\u95f4\u7528\u4ec0\u4e48\u4f20\u6570\u636e&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u73af\u5f62\u7f13\u51b2&#xff08;S16&#xff09;&#xff0c;\u4e2d\u65ad\u53ea\u5199\u7d22\u5f15\u3001\u4e3b\u5faa\u73af\u53ea\u8bfb\u7d22\u5f15\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">E5. I2C \u4e2d\u65ad\u6a21\u5f0f&#xff08;10.2&#xff09;\u548c SPI \u4e2d\u65ad\u6a21\u5f0f&#xff08;10.3&#xff09;\u7684\u72b6\u6001\u673a\u4e3a\u4ec0\u4e48\u590d\u6742&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u4e00\u6b21 I2C \u8bfb\u53ef\u80fd\u8981\u7ecf\u5386&#xff1a;\u8d77\u59cb \u2192 \u5730\u5740&#043;W \u2192 ACK \u2192 \u5bc4\u5b58\u5668\u5730\u5740 \u2192ACK \u2192 \u91cd\u590d\u8d77\u59cb \u2192 \u5730\u5740&#043;R \u2192 ACK \u2192 \u6536\u6570\u636e \u2192 NACK \u2192 \u505c\u6b62&#xff0c;\u6bcf\u4e00\u6b65\u90fd\u662f\u72ec\u7acb\u4e2d\u65ad\u4e8b\u4ef6&#xff0c;ISR \u91cc\u8981\u7528\u72b6\u6001\u673a\u63a8\u8fdb\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">SPI \u76f8\u5bf9\u7b80\u5355&#xff1a;TXE\/RXNE \u4e24\u4e2a\u4e8b\u4ef6&#xff0c;\u9010\u5b57\u8282\u63a8\u8fdb\u3002<\/span><\/li>\n<li><span style=\"color:#be191c\">\u8ffd\u95ee&#xff1a;\u600e\u4e48\u907f\u514d\u72b6\u6001\u673a\u5199\u4e71&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u7528\u679a\u4e3e\u72b6\u6001 &#043; \u6bcf\u4e2a\u4e8b\u4ef6\u4e00\u4e2a case&#xff0c;\u56de\u8c03\u91cc\u53ea\u6539\u72b6\u6001\u548c\u642c\u6570\u636e\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">E6. \u4e2d\u65ad\u4f18\u5148\u7ea7\u603b\u539f\u5219&#xff1a;\u4e32\u53e3\/I2C\/SPI\/\u5b9a\u65f6\u5668\/\u6309\u952e\u600e\u4e48\u6392&#xff1f;&#xff08;\u7efc\u5408\u9898&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u539f\u5219&#xff1a;\u6570\u636e\u6613\u4e22 &gt; \u63a7\u5236\u5b9e\u65f6\u6027 &gt; \u975e\u5b9e\u65f6\u4efb\u52a1&#xff1b;\u540c\u62a2\u5360\u7ea7\u7528\u5b50\u4f18\u5148\u7ea7\u6392\u5e8f\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u63a8\u8350\u793a\u4f8b&#xff1a;\u4e32\u53e3\u63a5\u6536\/\u5b9a\u65f6\u5668\u63a7\u5236&#xff08;\u9ad8\u62a2\u5360&#xff09;\u2192 I2C\/SPI \u901a\u4fe1&#xff08;\u4e2d&#xff09;\u2192 \u6309\u952e\/\u4f4e\u4f18\u5148\u7ea7\u4e8b\u4ef6&#xff08;\u4f4e&#xff09;&#xff1b;PendSV \u6700\u4f4e\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">E7. \u4e2d\u65ad\u4e0e DMA \u534f\u4f5c\u7684\u603b\u6846\u67b6&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u89c4\u5219&#xff1a;\u9010\u5b57\u8282\/\u5c0f\u6570\u636e\u7528\u4e2d\u65ad&#xff0c;\u5927\u5757\u6570\u636e\u7528 DMA &#043; \u5b8c\u6210\u4e2d\u65ad&#xff1b;DMA \u5b8c\u6210\u4e2d\u65ad\u91cc\u7f6e&#034;\u6570\u636e\u5c31\u7eea&#034;\u6807\u5fd7&#xff0c;\u4e3b\u5faa\u73af\u6d88\u8d39\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;DMA \u548c\u4e2d\u65ad\u80fd\u540c\u65f6\u7528\u4e8e\u540c\u4e00\u5916\u8bbe\u5417&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u80fd&#xff0c;\u5206\u5de5\u4e0d\u540c&#xff08;DMA \u642c\u6570\u636e\u3001\u4e2d\u65ad\u5904\u7406\u9519\u8bef\/IDLE\/\u5b8c\u6210&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">E8. \u4e2d\u65ad\u91cc\u5e38\u89c1\u7684 3 \u4e2a&#034;\u6b7b\u9501&#034;\u53cd\u4f8b&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u2460 ISR \u91cc\u8c03 HAL_Delay&#xff08;\u7b49 SysTick&#xff0c;\u4f46 SysTick \u4f18\u5148\u7ea7\u4f4e\u8fdb\u4e0d\u6765&#xff09;\u2192 \u5361\u6b7b&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u2461 ISR \u91cc printf&#xff08;\u4e32\u53e3\u4e2d\u65ad\u81ea\u5df1\u7b49\u81ea\u5df1&#xff09;\u2192 \u5361\u6b7b&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u2462 ISR \u91cc\u5173\u4e2d\u65ad\u5fd8\u4e86\u5f00\/\u4e34\u754c\u533a\u8fc7\u957f \u2192 \u7cfb\u7edf\u5931\u806a\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u600e\u4e48\u9884\u9632&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 ISR \u53ea\u7f6e\u6807\u5fd7 &#043; \u642c\u6570\u636e&#xff1b;\u8c03\u7528\u7684\u4efb\u4f55\u51fd\u6570\u5fc5\u987b\u53ef\u91cd\u5165\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">E9. \u5f31\u5f15\u7528\u56de\u8c03\u7684\u5b9e\u6218&#xff1a;\u600e\u4e48\u5199\u4e00\u4e2a&#034;\u7528\u6237\u53ef\u8986\u76d6&#034;\u7684\u9a71\u52a8&#xff1f;<\/span><\/p>\n<p>\/\/ \u9a71\u52a8\u5e93&#xff08;\u5f31\u5b9e\u73b0&#xff09;<br \/>\n__weak void OnDataReady(uint8_t *buf, uint16_t len) { }<br \/>\n\/\/ \u7528\u6237\u5de5\u7a0b&#xff08;\u5f3a\u7b26\u53f7&#xff0c;\u8986\u76d6\u5e93\u9ed8\u8ba4&#xff09;<br \/>\nvoid OnDataReady(uint8_t *buf, uint16_t len) {<br \/>\n    \/* \u7528\u6237\u81ea\u5df1\u7684\u5904\u7406 *\/<br \/>\n}<\/p>\n<ul>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u5de5\u7a0b\u91cc\u56de\u8c03\u540d\u51b2\u7a81\u600e\u4e48\u529e&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u52a0\u524d\u7f00\/\u547d\u540d\u7a7a\u95f4\u98ce\u683c&#xff08;\u5982 APP_OnDataReady&#xff09;&#xff0c;\u6216\u7528\u51fd\u6570\u6307\u9488\u6ce8\u518c\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">E10. \u4e2d\u65ad\u76f8\u5173\u9762\u8bd5\u8ba1\u7b97&#xff1a;\u4e00\u4e2a 921600 \u6ce2\u7279\u7387\u7684\u4e32\u53e3&#xff0c;\u4e2d\u65ad\u6a21\u5f0f CPU \u5360\u7528\u591a\u5927&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">921600 bps \u2248 92,160 \u5b57\u8282\/\u79d2&#xff08;10bit\/\u5e27&#xff09;\u2192 \u7ea6 10.7\u00b5s \u4e00\u4e2a\u5b57\u8282&#xff1b;\u82e5 ISR \u5904\u7406&#043;\u538b\u6808\u51fa\u6808\u82b1 23\u00b5s&#xff0c;CPU \u5360\u7528\u7ea6 **2030%**&#xff0c;\u8fd8\u6709\u5b9a\u65f6\u5668\/\u5176\u4ed6\u4e2d\u65ad \u2192 \u660e\u663e\u4e0d\u591f\u7528 \u2192 \u8fd9\u5c31\u662f\u5fc5\u987b\u4e0a DMA \u7684\u91cf\u5316\u7406\u7531\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<h3><span style=\"color:#1a439c\">\u7efc\u5408\u5b9e\u6218\u9898&#xff08;\u9762\u8bd5\u538b\u8f74&#xff09;X1\u2013X3<\/span><\/h3>\n<p><span style=\"color:#b95514\">X1. \u8bbe\u8ba1\u9898&#xff1a;\u7528 STM32 \u505a\u4e00\u4e2a\u6e29\u6e7f\u5ea6\u91c7\u96c6\u4e0a\u62a5\u7cfb\u7edf&#xff0c;\u600e\u4e48\u5206\u914d\u4e2d\u65ad\u4e0e\u8f6e\u8be2&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u65b9\u6848&#xff1a;I2C \u8bfb\u4f20\u611f\u5668&#xff08;\u4e2d\u65ad\/DMA&#xff0c;\u4e0d\u963b\u585e&#xff09;\u2192 \u6570\u636e\u5728\u56de\u8c03\u91cc\u5165\u73af\u5f62\u961f\u5217 \u2192 \u4e3b\u5faa\u73af\u5904\u7406 \u2192 \u4e32\u53e3\u5b9a\u65f6\u4e0a\u62a5&#xff08;\u8f6e\u8be2\u53d1\u9001\u7b80\u5355\u573a\u666f\/DMA \u5927\u573a\u666f&#xff09;\u2192 \u6309\u952e\u6539\u914d\u7f6e&#xff08;EXTI \u4e2d\u65ad &#043; \u6d88\u6296&#xff09;\u2192 LED \u72b6\u6001\u6307\u793a&#xff08;GPIO \u63a8\u633d&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8003\u70b9&#xff1a;\u6a21\u5757\u5316\u3001\u4e2d\u65ad\u804c\u8d23\u5212\u5206\u3001\u7f13\u51b2\u8bbe\u8ba1\u3001\u65f6\u949f\/\u6ce2\u7279\u7387\u6b63\u786e\u6027\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">X2. \u73b0\u573a\u624b\u6495&#xff1a;\u6a21\u62df I2C \u5b8c\u6574\u6536\u53d1\u4e00\u5b57\u8282<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u5199&#xff1a;Start \u2192 SendByte(addr|W) \u2192 \u7b49 ACK \u2192 SendByte(reg) \u2192 \u7b49 ACK \u2192 \u6570\u636e \u2192 \u7b49 ACK \u2192 Stop&#xff1b;\u8bfb\u518d\u52a0 RepeatStart \u6362 R\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8003\u70b9&#xff1a;\u65f6\u5e8f\u56db\u6b65&#xff08;\u8d77\u59cb\/\u505c\u6b62\/\u6570\u636e\u6709\u6548\/ACK&#xff09;&#043; \u6a21\u62df\u4f4d\u64cd\u4f5c&#xff08;\u4f4d\u5e26\u6216\u76f4\u63a5 IO&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">X3. \u6545\u969c\u9898&#xff1a;\u4e0a\u7535\u540e\u4e32\u53e3\u6253\u5370\u4e71\u7801\u3001LED \u4e0d\u4eae\u3001I2C \u8bfb\u4f20\u611f\u5668\u5168\u662f 0xFF&#xff0c;\u600e\u4e48\u6392\u67e5&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u5148\u67e5\u65f6\u949f&#xff1a;HSE \u6709\u6ca1\u6709\u8d77\u632f\u3001PLL \u6709\u6ca1\u6709\u9501\u3001APB \u5206\u9891\u5bf9\u6ca1\u5bf9&#xff08;\u4e00\u7968\u5426\u51b3&#xff0c;\u5168\u6302&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u518d\u67e5 GPIO&#xff1a;\u65f6\u949f\u5f00\u4e86\u6ca1\u3001\u6a21\u5f0f\/\u590d\u7528\u914d\u4e86\u6ca1\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u518d\u9010\u4e2a\u5916\u8bbe&#xff1a;\u6ce2\u7279\u7387\u7b97\u5bf9\u6ca1\u3001\u5730\u5740\/\u4e0a\u62c9\/\u65f6\u5e8f\u5bf9\u6ca1\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8003\u70b9&#xff1a;\u5148\u7cfb\u7edf\u540e\u5916\u8bbe\u7684\u6392\u67e5\u987a\u5e8f&#xff0c;\u5d4c\u5165\u5f0f\u5de5\u7a0b\u5e08\u7684\u57fa\u672c\u7d20\u517b\u3002<\/span><\/li>\n<\/ul>\n<h3><\/h3>\n<hr \/>\n<h2><span style=\"color:#1a439c\">\u4e09\u5927\u4e32\u884c\u901a\u4fe1\u534f\u8bae\u9762\u8bd5\u9898\u5e93&#xff08;USART \/ I2C \/ SPI \u00b7 51 \u9898&#xff09;<\/span><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"431\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261003124935-6ac0f9dfb7e0c.png\" width=\"860\" \/><\/p>\n<h3><span style=\"color:#1a439c\">\u4e00\u3001USART \u4e32\u53e3\u7bc7&#xff08;U1\u2013U17&#xff09;<\/span><\/h3>\n<p><span style=\"color:#b95514\">U1. UART \u548c USART \u6709\u4ec0\u4e48\u533a\u522b&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">USART \u652f\u6301\u540c\u6b65\u6a21\u5f0f&#xff08;\u5e26 CK \u65f6\u949f\u5f15\u811a&#xff0c;\u53ef\u5f53 SPI \u4e3b\u673a&#xff09;\u3001\u5f02\u6b65\u3001\u5355\u7ebf\u534a\u53cc\u5de5\u3001LIN\u3001\u667a\u80fd\u5361\u3001IrDA\u3001Modbus&#xff1b;UART \u53ea\u6709\u5f02\u6b65\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">STM32F1&#xff1a;USART1\/2\/3 \u662f\u5b8c\u6574 USART&#xff0c;UART4\/5 \u53ea\u662f UART&#xff08;\u65e0 CK \u5f15\u811a&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U2. \u6ce2\u7279\u7387\u600e\u4e48\u7b97&#xff1f;\u8bef\u5dee\u8981\u6c42&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u516c\u5f0f&#xff1a;USARTDIV &#061; fck \/ (16 \u00d7 Baud)&#xff0c;\u7ed3\u679c\u5b58 BRR&#xff08;\u9ad8 12 \u4f4d\u6574\u6570 &#043; \u4f4e 4 \u4f4d\u5c0f\u6570&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u4f8b&#xff1a;72MHz\u30019600 \u2192 USARTDIV&#061;468.75 \u2192 BRR&#061;0x1D4C&#xff0c;\u6b63\u597d 9600\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8bef\u5dee &lt; 2%&#xff08;\u786c\u4ef6 3\/16 \u4f4d\u91c7\u6837\u5bb9\u5dee&#xff09;&#xff1b;HSI \u7cbe\u5ea6 \u00b11% \u53ef\u80fd\u53e0\u52a0\u5230\u5371\u9669\u533a&#xff0c;\u9ad8\u7cbe\u5ea6\u5fc5\u987b HSE\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">8N1 \u4e00\u5e27 10 bit \u2192 9600bps \u2248 960 \u5b57\u8282\/\u79d2\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u5e38\u89c1\u5751&#xff1a;USART2\/3 \u5728 APB1&#061;36MHz&#xff0c;\u62ff 72MHz \u7b97\u5fc5\u4e71\u7801\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U3. \u5e27\u683c\u5f0f\u6709\u54ea\u4e9b\u53c2\u6570&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u8d77\u59cb\u4f4d(\u4f4e 1bit) \u2192 \u6570\u636e\u4f4d(8\/9, LSB \u5148\u53d1) \u2192 \u6821\u9a8c(\u65e0\/\u5947\/\u5076) \u2192 \u505c\u6b62\u4f4d(0.5\/1\/1.5\/2)\u3002\u7ecf\u5178 8N1\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u6821\u9a8c\u53ea\u80fd\u68c0\u5355 bit \u9519&#xff0c;\u4e0d\u80fd\u7ea0\u9519&#xff1b;\u7528\u6821\u9a8c\u65f6\u6570\u636e\u4f4d\u8bbe 9\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U4. \u8f6e\u8be2 \/ \u4e2d\u65ad \/ DMA \u4e09\u79cd\u6536\u53d1\u65b9\u5f0f\u5bf9\u6bd4&#xff1f;<\/span><\/p>\n<table>\n<tr><span style=\"color:#0d0016\">\u65b9\u5f0f<\/span><span style=\"color:#0d0016\">CPU \u5360\u7528<\/span><span style=\"color:#0d0016\">\u5b9e\u65f6\u6027<\/span><span style=\"color:#0d0016\">\u9002\u7528<\/span><\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#0d0016\">\u8f6e\u8be2<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u5fd9\u7b49 100%<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u963b\u585e<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u8c03\u8bd5\u3001\u4f4e\u901f\u5c11\u91cf<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u4e2d\u65ad<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u6bcf\u5b57\u8282\u8fdb\u51fa ISR<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u53ca\u65f6<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u547d\u4ee4\u4ea4\u4e92\u3001\u4e0d\u5b9a\u957f\u5c0f\u5305<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">DMA<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u642c\u8fd0\u4e0d\u5360 CPU<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u6574\u5757\u6536\u5b8c\u624d\u77e5<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u9ad8\u901f\u5927\u5757\u3001\u4e0d\u5b9a\u957f&#043;IDLE<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<p><span style=\"color:#b95514\">U5. IDLE \u7a7a\u95f2\u4e2d\u65ad &#043; DMA \u4e0d\u5b9a\u957f\u63a5\u6536\u6d41\u7a0b&#xff1f;&#xff08;\u5fc5\u8003&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u2460 DMA \u5faa\u73af\u6a21\u5f0f\u6536\u8fdb\u7f13\u51b2 \u2192 \u2461 \u5f00 IDLE \u4e2d\u65ad \u2192 \u2462 \u4e00\u5e27\u6536\u5b8c\u603b\u7ebf\u7a7a\u95f2\u89e6\u53d1 IDLE \u2192 \u2463 \u5148\u8bfb SR \u518d\u8bfb DR \u6e05\u6807\u5fd7 \u2192 \u2464 len &#061; BUFSZ \u2212 DMA_GetCounter() \u2192 \u2465 \u7f6e\u5e27\u5b8c\u6210\u6807\u5fd7 \u2192 \u2466 \u5173 DMA \u91cd\u7f6e CNDTR \u7ee7\u7eed\u6536\u3002<\/span><\/li>\n<\/ul>\n<p>void USART1_IRQHandler(void) {<br \/>\n    if (USART1-&gt;SR &amp; USART_SR_IDLE) {<br \/>\n        USART1-&gt;SR; USART1-&gt;DR;                    \/\/ \u6e05 IDLE<br \/>\n        uint16_t len &#061; RX_BUF_SIZE &#8211; DMA1_Channel5-&gt;CNDTR;<br \/>\n        frame_ready &#061; 1;<br \/>\n        DMA_Cmd(DMA1_Channel5, DISABLE);<br \/>\n        DMA1_Channel5-&gt;CNDTR &#061; RX_BUF_SIZE;        \/\/ \u5173\u95ed\u72b6\u6001\u624d\u80fd\u5199<br \/>\n        DMA_Cmd(DMA1_Channel5, ENABLE);<br \/>\n    }<br \/>\n}<\/p>\n<hr \/>\n<p><span style=\"color:#b95514\">U6. TXE \u548c TC \u6709\u4ec0\u4e48\u533a\u522b&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">TXE &#061; DR \u7a7a&#xff0c;\u53ef\u5199\u4e0b\u4e00\u5b57\u8282&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">TC &#061; \u79fb\u4f4d\u5bc4\u5b58\u5668\u4e5f\u53d1\u5b8c\u4e86&#xff0c;\u5b57\u8282\u771f\u6b63\u4e0a\u5f15\u811a\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u53ea\u7b49 TXE \u5c31\u5173\u4e32\u53e3\/\u5207 485 \u65b9\u5411 \u2192 \u6700\u540e\u4e00\u5b57\u8282\u4e22\u5931&#xff1b;\u6536\u5c3e\u5fc5\u987b\u7b49 TC\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U7. ORE \u6ea2\u51fa\u9519\u8bef\u600e\u4e48\u5904\u7406&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u539f\u56e0&#xff1a;RXNE&#061;1 \u672a\u8bfb\u8d70\u65f6\u65b0\u5b57\u8282\u5230\u8fbe \u2192 \u4e22\u6570\u636e\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u5904\u7406&#xff1a;\u8bfb SR \u518d\u8bfb DR \u6e05\u6807\u5fd7&#xff1b;\u4e2d\u65ad\u5904\u7406\u8981\u5feb\u6216\u6539 DMA\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u540c\u7c7b\u6807\u5fd7&#xff1a;FE&#xff08;\u5e27\u9519&#xff09;\u3001NE&#xff08;\u566a\u58f0&#xff09;\u3001PE&#xff08;\u6821\u9a8c\u9519&#xff09;&#xff0c;\u6e05\u9664\u65b9\u5f0f\u76f8\u540c&#xff08;\u8bfb SR&#043;DR&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U8. \u4e3a\u4ec0\u4e48\u4e32\u53e3\u4e2d\u65ad\u91cc&#034;\u5148\u8bfb SR \u518d\u8bfb DR&#034;&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">RXNE\/IDLE\/ORE \u7684\u6e05\u9664\u6761\u4ef6\u662f&#034;\u8bfb SR &#043; \u8bfb DR&#034;\u7ec4\u5408\u52a8\u4f5c&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u987a\u5e8f\u53cd\u4e86\u4f1a\u8bef\u6e05\/\u6e05\u4e0d\u6389 \u2192 \u53cd\u590d\u8fdb\u4e2d\u65ad\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U9. printf \u91cd\u5b9a\u5411\u600e\u4e48\u505a&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u91cd\u5199 fputc&#xff08;\u7b49 TXE \u2192 \u5199 DR&#xff09;&#xff1b;Keil \u52fe Use MicroLIB \u6216 GCC \u52a0 -specs&#061;nosys.specs \u7981\u534a\u4e3b\u673a&#xff0c;\u5426\u5219\u5361\u6b7b\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">ISR \u91cc\u7981\u6b62 printf&#xff08;\u53ef\u80fd\u548c\u4e32\u53e3\u4e2d\u65ad\u4e92\u76f8\u7b49\u5f85\u6b7b\u9501&#xff09;&#xff1b;RTOS \u4e0b\u9700\u52a0\u9501\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U10. \u4e71\u7801 \/ \u6536 0xFF \u600e\u4e48\u6392\u67e5&#xff1f;<\/span><\/p>\n<li><span style=\"color:#0d0016\">\u6ce2\u7279\u7387\u4e00\u81f4&#xff1f;\u65f6\u949f\u6e90\/APB \u5206\u9891\u7b97\u5bf9&#xff1f;<\/span><span style=\"color:#0d0016\">2. \u5e27\u683c\u5f0f\u4e00\u81f4&#xff1f;3. TX\u2194RX \u4ea4\u53c9\u3001\u5171\u5730&#xff1f;4. \u7535\u5e73\u6807\u51c6\u5339\u914d&#xff08;TTL\/RS232\/RS485&#xff09;&#xff1f;5. \u5f15\u811a AF \u914d\u597d\u3001\u4e32\u53e3\u65f6\u949f\u5f00\u4e86&#xff1f;6. \u793a\u6ce2\u5668\u91cf\u7a7a\u95f2\u7535\u5e73&#xff08;\u5e94\u4e3a\u9ad8&#xff09;&#043; \u5e27\u5bbd\u3002<\/span><\/li>\n<ul>\n<li><span style=\"color:#0d0016\">\u6536 0xFF \u5e38\u89c1&#xff1a;RX \u60ac\u7a7a\u3001\u63a5\u7ebf\u6ca1\u63a5\u3001\u7535\u5e73\u4e0d\u5339\u914d\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U11. \u5f15\u811a\u914d\u7f6e&#xff1a;F1 \u91cd\u6620\u5c04 vs F4 \u590d\u7528&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">F1&#xff1a;\u590d\u7528\u63a8\u633d &#043; AFIO \u91cd\u6620\u5c04&#xff08;USART1 \u53ef PA9\/10 \u6216 PB6\/7&#xff09;&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">F<\/span><span style=\"color:#0d0016\">4&#xff1a;GPIO_AF7_USART1 \u9009\u590d\u7528\u529f\u80fd&#xff0c;\u65e0 AFIO\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u65f6\u949f&#xff1a;USART1 \u5728 APB2&#xff0c;USART2\/3 \u5728 APB1&#xff1b;\u521d\u59cb\u5316\u987a\u5e8f&#xff1a;\u5f00\u65f6\u949f \u2192 \u914d\u5f15\u811a \u2192 \u914d\u4e32\u53e3\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U12. \u591a\u5b57\u8282\u534f\u8bae\u600e\u4e48\u89e3\u6790&#xff1f;&#xff08;\u7c98\u5305\/\u62c6\u5305&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u72b6\u6001\u673a&#xff1a;\u5e27\u5934(AA 55) \u2192 \u957f\u5ea6 \u2192 \u6570\u636e \u2192 \u6821\u9a8c(CRC16\/\u548c\u6821\u9a8c)&#xff0c;\u72b6\u6001\u9519\u4e71\u56de\u5e27\u5934\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u65e0\u957f\u5ea6\u5b57\u6bb5\u65f6&#xff1a;\u5b9a\u957f\u5e27 \/ \u5e27\u5c3e \/ \u7a7a\u95f2\u8d85\u65f6\u5224\u5b9a\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U13. \u73af\u5f62\u7f13\u51b2\u600e\u4e48\u5b9e\u73b0&#xff1f;&#xff08;\u624b\u6495&#xff09;<\/span><\/p>\n<p>#define RB_SIZE 256                    \/\/ 2 \u7684\u5e42\u624d\u80fd\u7528 &amp;<br \/>\ntypedef struct { uint8_t buf[RB_SIZE]; volatile uint16_t head, tail; } ring_t;<br \/>\n\/\/ \u7a7a&#xff1a;head&#061;&#061;tail&#xff1b;\u6ee1&#xff1a;(head&#043;1)&amp;mask &#061;&#061; tail&#xff08;\u6d6a\u8d39\u4e00\u683c\u6cd5&#xff09;<br \/>\nvoid rb_put(ring_t *r, uint8_t d) {<br \/>\n    uint16_t n &#061; (r-&gt;head &#043; 1) &amp; (RB_SIZE &#8211; 1);<br \/>\n    if (n !&#061; r-&gt;tail) { r-&gt;buf[r-&gt;head] &#061; d; r-&gt;head &#061; n; }<br \/>\n}<br \/>\nint rb_get(ring_t *r, uint8_t *d) {<br \/>\n    if (r-&gt;head &#061;&#061; r-&gt;tail) return 0;<br \/>\n    *d &#061; r-&gt;buf[r-&gt;tail]; r-&gt;tail &#061; (r-&gt;tail &#043; 1) &amp; (RB_SIZE &#8211; 1); return 1;<br \/>\n}<\/p>\n<hr \/>\n<p><span style=\"color:#b95514\">U14. RS485 \u65b9\u5411\u63a7\u5236\u6ce8\u610f\u4ec0\u4e48&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">DE\/RE \u5f15\u811a&#xff1a;\u53d1 DE&#061;1&#xff0c;\u6536 DE&#061;0&#xff1b;\u53d1\u9001\u5b8c\u5fc5\u987b\u7b49 TC \u518d\u62c9\u4f4e DE&#xff0c;\u5426\u5219\u5c3e\u5b57\u8282\u4e22\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">485 \u534a\u53cc\u5de5&#xff0c;\u81ea\u5df1\u53d1\u65f6\u4f1a\u6536\u5230\u81ea\u5df1&#xff08;\u56de\u73af&#xff09;&#xff0c;\u4e0d\u80fd\u8fb9\u53d1\u8fb9\u6536\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U15. \u5168\u53cc\u5de5\/\u534a\u53cc\u5de5\/\u5355\u7ebf\u6a21\u5f0f&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u5168\u53cc\u5de5&#xff1a;TX\/RX \u72ec\u7acb&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u5355\u7ebf\u534a\u53cc\u5de5&#xff1a;\u590d\u7528\u4e00\u4e2a\u5f15\u811a&#xff08;1.5 \u505c\u6b62\u4f4d&#xff09;&#xff1b;USART \u540c\u6b65\u6a21\u5f0f\u53ef\u8f93\u51fa CK \u5f53 SPI \u7528\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U16. \u4e32\u53e3 DMA \u914d\u7f6e\u8981\u70b9&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u65b9\u5411\u3001\u5916\u8bbe\u5730\u5740 &amp;USARTx-&gt;DR\u3001\u6570\u636e\u5bbd\u5ea6 8 \u4f4d\u3001\u53d1\u9001 normal \/ \u63a5\u6536 circular\u3001\u53d1\u9001\u5b8c\u6210\u7528 TC \u6536\u5c3e\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u5927\u7f13\u51b2\u5efa\u8bae 4 \u5b57\u8282\u5bf9\u9f50&#xff08;32 \u4f4d\u5bbd\u5ea6\u65f6\u5fc5\u9700&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U17. \u4e32\u53e3\u9ad8\u9891\u8ffd\u95ee\u901f\u7b54<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u4e2d\u65ad\u4f1a\u4e22\u6570\u636e\u5417&#xff1f;\u2192 \u4f1a&#xff0c;ISR \u4e0d\u53ca\u65f6 \u2192 ORE\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u4e00\u5e27\u6700\u591a\u4f20\u591a\u5c11&#xff1f;\u2192 \u534f\u8bae\u65e0\u4e0a\u9650&#xff0c;\u53d7\u7f13\u51b2\/\u8d85\u65f6\u7ea6\u675f\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u600e\u4e48\u77e5\u9053\u4e00\u5e27\u6536\u5b8c\u4e86&#xff1f;\u2192 IDLE \/ \u957f\u5ea6\u5b57\u6bb5 \/ \u5e27\u5c3e \/ \u8d85\u65f6\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<h3><span style=\"color:#1a439c\">\u4e8c\u3001I2C \u7bc7&#xff08;I1\u2013I17&#xff09;<\/span><\/h3>\n<p><span style=\"color:#b95514\">I1. I2C \u7269\u7406\u5c42\u7279\u70b9&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u4e24\u7ebf&#xff1a;SCL &#043; SDA&#xff1b;\u5f00\u6f0f &#043; \u5916\u90e8\u4e0a\u62c9&#xff1b;\u534a\u53cc\u5de5&#xff1b;\u652f\u6301\u591a\u4e3b\u673a\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u901f\u5ea6&#xff1a;\u6807\u51c6 100k \/ \u5feb\u901f 400k \/ \u5feb\u901f&#043; 1M\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4e3a\u4ec0\u4e48\u5f00\u6f0f&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u624d\u80fd\u7ebf\u4e0e&#xff0c;\u591a\u8bbe\u5907\u5171\u4eab\u603b\u7ebf\u4e0d\u77ed\u8def&#xff1b;\u4e0a\u62c9\u8d1f\u8d23\u62c9\u9ad8\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I2. \u65f6\u5e8f\u56db\u4ef6\u4e8b&#xff1a;\u8d77\u59cb\/\u505c\u6b62\/\u6570\u636e\u6709\u6548\/ACK&#xff1f;&#xff08;\u624b\u6495\u57fa\u7840&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u8d77\u59cb&#xff1a;SCL \u9ad8\u65f6 SDA \u62c9\u4f4e&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u505c\u6b62&#xff1a;SCL \u9ad8\u65f6 SDA \u62c9\u9ad8\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u6570\u636e\u6709\u6548&#xff1a;SCL \u9ad8\u671f\u95f4 SDA \u5fc5\u987b\u7a33\u5b9a&#xff0c;SCL \u4f4e\u65f6\u624d\u5141\u8bb8\u53d8\u5316\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">ACK&#xff1a;\u7b2c 9 \u4e2a\u65f6\u949f&#xff0c;\u63a5\u6536\u65b9\u62c9\u4f4e SDA&#xff1b;\u4e3b\u673a\u6536\u5b8c\u6700\u540e\u5b57\u8282\u56de NACK \u518d\u505c\u6b62\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I3. \u5730\u5740\u673a\u5236&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u7b2c\u4e00\u5b57\u8282 &#061; 7 \u4f4d\u4ece\u673a\u5730\u5740 &#043; 1 \u4f4d R\/W&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u5668\u4ef6\u5730\u5740 &#061; \u82af\u7247\u56fa\u5b9a\u4f4d &#043; \u5f15\u811a\u914d\u7f6e\u4f4d&#xff08;A0~A2&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u540c\u5730\u5740\u51b2\u7a81&#xff1a;\u6539\u5f15\u811a\u6216\u5206\u603b\u7ebf\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I4. \u5b8c\u6574\u8bfb\/\u5199\u6d41\u7a0b&#xff08;EEPROM \u4f8b&#xff09;&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u5199&#xff1a;\u8d77\u59cb \u2192 \u5730\u5740&#043;W \u2192 ACK \u2192 \u5bc4\u5b58\u5668\u5730\u5740(2B) \u2192 ACK \u2192 \u6570\u636e \u2192 ACK \u2192 \u505c\u6b62\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8bfb&#xff1a;\u8d77\u59cb \u2192 \u5730\u5740&#043;W \u2192 \u5bc4\u5b58\u5668\u5730\u5740 \u2192 ACK \u2192 \u91cd\u590d\u8d77\u59cb \u2192 \u5730\u5740&#043;R \u2192 ACK \u2192 \u6536\u6570\u636e(\u6700\u540e NACK) \u2192 \u505c\u6b62\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I5. \u4e3a\u4ec0\u4e48\u8bfb\u8981&#034;\u91cd\u590d\u8d77\u59cb&#034;\u800c\u4e0d\u662f\u505c\u6b62\u518d\u5f00\u59cb&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u4fdd\u6301\u672c\u6b21\u64cd\u4f5c\u539f\u5b50\u6027&#xff0c;\u9632\u6b62\u505c\u6b62\u540e\u603b\u7ebf\u88ab\u5176\u4ed6\u4e3b\u673a\u63d2\u961f&#xff0c;\u5bc4\u5b58\u5668\u6307\u9488\u72b6\u6001\u88ab\u6253\u65ad\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I6. \u963b\u585e\u6a21\u5f0f HAL \u6e90\u7801\u5185\u90e8\u600e\u4e48\u8d70&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">HAL_I2C_Mem_Read&#xff1a;\u53d1\u8d77\u59cb&#043;\u5730\u5740&#xff08;\u7b49 TXIS&#xff09;\u2192 \u53d1\u5bc4\u5b58\u5668\u5730\u5740&#xff08;\u7b49 ACK&#xff09;\u2192 \u91cd\u590d\u8d77\u59cb \u2192 \u5730\u5740&#043;R \u2192 \u9010\u5b57\u8282\u6536&#xff08;\u524d N\u22121 \u56de ACK&#xff0c;\u6700\u540e NACK&#xff09;\u2192 \u505c\u6b62&#xff1b;\u5168\u7a0b HAL_GetTick \u8d85\u65f6\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u672c\u8d28\u662f\u4e2d\u65ad\u72b6\u6001\u673a &#043; \u5916\u5c42\u5fd9\u7b49\u7684\u963b\u585e\u8c03\u7528\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I7. \u603b\u7ebf\u5361\u6b7b&#xff08;SDA \u88ab\u62c9\u4f4e&#xff09;\u600e\u4e48\u6062\u590d&#xff1f;<\/span><\/p>\n<p>for (int i &#061; 0; i &lt; 9; i&#043;&#043;)<br \/>\n{ SCL_H(); delay(); SCL_L(); delay(); }  \/\/ 9 \u4e2a\u8109\u51b2<br \/>\nI2C_Stop();                              \/\/ \u8865\u505c\u6b62<\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u539f\u7406&#xff1a;9 \u4e2a\u65f6\u949f\u5f3a\u5236\u63a8\u8fdb\u4ece\u673a\u5185\u90e8\u72b6\u6001&#xff0c;\u8ba9\u5b83\u91ca\u653e SDA\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I8. \u6536\u4e0d\u5230 ACK&#xff08;NACK&#xff09;\u600e\u4e48\u6392\u67e5&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u5730\u5740\u5bf9\u4e0d\u5bf9&#xff08;\u624b\u518c&#xff09;\u2192 \u5668\u4ef6\u4e0a\u7535\u6ca1 \u2192 \u4e0a\u62c9\u7535\u963b\u6709\u6ca1\u6709&#xff08;SDA \u7a7a\u95f2\u662f\u5426\u9ad8&#xff09;\u2192 SCL\/SDA \u63a5\u53cd \u2192 \u4ece\u673a\u5361\u6b7b\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I9. \u4e0a\u62c9\u7535\u963b\u600e\u4e48\u53d6\u503c&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u7535\u963b\u5c0f \u2192 \u8fb9\u6cbf\u5feb\u53ef\u8dd1\u9ad8\u901f&#xff0c;\u4f46\u529f\u8017\u5927&#xff1b;\u5927 \u2192 \u7701\u7535\u4f46\u8fb9\u6cbf\u6162\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">3.3V&#xff1a;100k \u7528 4.7k10k&#xff0c;400k \u7528 2.2k4.7k&#xff1b;\u5668\u4ef6\u591a\/\u5bb9\u6027\u5927\u8981\u66f4\u5c0f\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I10. \u786c\u4ef6 I2C vs \u6a21\u62df I2C&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u6a21\u62df&#xff1a;\u4efb\u610f\u5f15\u811a\u3001\u65f6\u5e8f\u53ef\u63a7\u3001\u907f\u5f00 F1 \u786c\u4ef6 I2C \u7684\u5df2\u77e5 errata&#xff0c;\u5360 CPU\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u786c\u4ef6&#xff1a;\u81ea\u52a8\u65f6\u5e8f\u3001\u53ef DMA\/\u4e2d\u65ad\u3001\u7701 CPU&#xff1b;F4 \u540e\u57fa\u672c\u7a33\u5b9a\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u9762\u8bd5\u70b9&#xff1a;\u80fd\u8bf4\u51fa F1 \u786c\u4ef6 I2C \u6709\u52d8\u8bef&#xff08;\u5361\u6b7b\/\u603b\u7ebf\u9519\u8bef&#xff09;\u662f\u52a0\u5206\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I11. I2C \u4e2d\u65ad\u6a21\u5f0f\u4e3a\u4ec0\u4e48\u8981\u6709\u72b6\u6001\u673a&#xff1f;&#xff08;10.2 \u6df1\u5ea6&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u4e00\u6b21\u8bfb\u6709 6&#043; \u4e2a\u4e8b\u4ef6&#xff08;\u8d77\u59cb\/\u5730\u5740 ACK\/\u5bc4\u5b58\u5668\/\u91cd\u590d\u8d77\u59cb\/\u5730\u5740 R\/\u6570\u636e\/NACK\/\u505c\u6b62&#xff09;&#xff0c;\u6bcf\u4e2a\u4e8b\u4ef6\u4e00\u6b21 ISR&#xff0c;\u8c03\u7528\u65e9\u8fd4\u56de \u2192 \u5fc5\u987b\u7528\u679a\u4e3e\u72b6\u6001\u8bb0\u5f55&#034;\u8d70\u5230\u54ea\u4e00\u6b65&#034;\u3002<\/span><\/li>\n<\/ul>\n<p>typedef enum { ST_START, ST_ADDR_W, ST_WAIT_ACK1, ST_SEND_REG,<br \/>\n               ST_REPEAT_START, ST_ADDR_R, ST_READ, ST_SEND_NACK, ST_STOP } i2c_state_t;<\/p>\n<hr \/>\n<p><span style=\"color:#b95514\">I12. \u591a\u4e3b\u673a\u4ef2\u88c1\u8c01\u8d62&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u540c\u53d1 1 \u6ca1\u4e8b&#xff1b;\u53d1 1 \u7684\u4e3b\u673a\u9047\u5230\u5bf9\u65b9\u53d1 0 \u2192 \u4e22\u4ef2\u88c1\u9000\u51fa&#xff08;\u5f00\u6f0f\u7ebf\u4e0e&#xff09;&#xff0c;\u603b\u7ebf\u5f52\u53d1 0 \u8005&#xff0c;\u6570\u636e\u4e0d\u635f\u574f\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I13. \u6a21\u62df I2C \u624b\u6495&#xff1a;Start\/SendByte\/ReadByte\/ACK<\/span><\/p>\n<p>void I2C_Start(void)  { SDA_H(); SCL_H(); delay(); SDA_L(); delay(); SCL_L(); }<br \/>\nvoid I2C_Stop(void)   { SDA_L(); SCL_H(); delay(); SDA_H(); delay(); }<br \/>\nvoid I2C_SendByte(uint8_t b) {<br \/>\n    for (int i &#061; 7; i &gt;&#061; 0; i&#8211;) {<br \/>\n        if (b &amp; (1 &lt;&lt; i)) SDA_H(); else SDA_L();<br \/>\n        SCL_H(); delay(); SCL_L(); delay();     \/\/ SCL \u9ad8\u65f6 SDA \u7a33\u5b9a<br \/>\n    }<br \/>\n}<br \/>\nuint8_t I2C_ReadByte(void) {<br \/>\n    uint8_t d &#061; 0; SDA_H();                     \/\/ \u91ca\u653e SDA \u8ba9\u4ece\u673a\u9a71\u52a8<br \/>\n    for (int i &#061; 7; i &gt;&#061; 0; i&#8211;) {<br \/>\n        SCL_H(); delay();<br \/>\n        if (SDA_READ()) d |&#061; (1 &lt;&lt; i);<br \/>\n        SCL_L(); delay();<br \/>\n    }<br \/>\n    return d;<br \/>\n}<br \/>\nuint8_t I2C_CheckACK(void) { SDA_H(); SCL_H(); delay(); uint8_t a &#061; !SDA_READ(); SCL_L(); return a; }<\/p>\n<hr \/>\n<p><span style=\"color:#b95514\">I14. EEPROM \u8bfb\u4e00\u5b57\u8282\u624b\u6495&#xff08;\u91cd\u590d\u8d77\u59cb &#043; NACK \u5168\u5728&#xff09;<\/span><\/p>\n<p>uint8_t EEPROM_ReadByte(uint16_t addr) {<br \/>\n    uint8_t d;<br \/>\n    I2C_Start();<br \/>\n    I2C_SendByte(0xA0); I2C_CheckACK();         \/\/ \u5730\u5740&#043;W<br \/>\n    I2C_SendByte(addr &gt;&gt; 8);   I2C_CheckACK();<br \/>\n    I2C_SendByte(addr &amp; 0xFF); I2C_CheckACK();<br \/>\n    I2C_Start();                                 \/\/ \u91cd\u590d\u8d77\u59cb<br \/>\n    I2C_SendByte(0xA1); I2C_CheckACK();          \/\/ \u5730\u5740&#043;R<br \/>\n    d &#061; I2C_ReadByte();<br \/>\n    I2C_SendACK(0);                              \/\/ \u6700\u540e\u4e00\u5b57\u8282 NACK<br \/>\n    I2C_Stop();<br \/>\n    return d;<br \/>\n}<\/p>\n<hr \/>\n<p><span style=\"color:#b95514\">I15. I2C \u5e38\u89c1\u5751\u901f\u67e5<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u6f0f\u4e0a\u62c9\u7535\u963b \u2192 \u901a\u4fe1\u5168\u5931\u8d25&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">SDA \u5728 SCL \u9ad8\u65f6\u53d8\u4e86 \u2192 \u4ece\u673a\u8bef\u5224\u6210\u8d77\u59cb\/\u505c\u6b62&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u591a\u5b57\u8282\u8bfb\u5fd8 NACK \u2192 \u4ece\u673a\u7ee7\u7eed\u53d1&#xff0c;\u603b\u7ebf\u4e71&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">ISR \u91cc\u505a\u6570\u636e\u5904\u7406 \u2192 \u62d6\u6b7b\u5176\u4ed6\u4e2d\u65ad\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I16. \u4e3a\u4ec0\u4e48 ISR \u91cc\u4e0d\u5904\u7406 I2C \u6570\u636e&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">I2C \u4e2d\u65ad\u5bc6\u96c6&#xff08;\u6bcf\u5b57\u8282\u81f3\u5c11\u4e00\u6b21&#xff09;&#xff0c;\u4e1a\u52a1\u903b\u8f91\u653e ISR \u4f1a\u963b\u585e\u5176\u4ed6\u4e2d\u65ad&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u56de\u8c03\u53ea\u642c\u7f13\u51b2 &#043; \u7f6e\u6807\u5fd7\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I17. I2C \u9ad8\u9891\u8ffd\u95ee\u901f\u7b54<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">I2C \u80fd\u50cf SPI \u4e00\u6837\u5168\u53cc\u5de5\u5417&#xff1f;\u2192 \u4e0d\u80fd&#xff0c;\u534a\u53cc\u5de5\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u6ca1\u6709\u4e0a\u62c9\u4f1a\u600e\u6837&#xff1f;\u2192 \u7535\u5e73\u4e0d\u786e\u5b9a&#xff0c;\u901a\u4fe1\u5931\u8d25\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u4ece\u673a\u600e\u4e48\u77e5\u9053\u81ea\u5df1\u88ab\u9009\u4e2d&#xff1f;\u2192 \u5730\u5740\u5339\u914d\u540e\u5e94\u7b54 ACK\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<h3><span style=\"color:#1a439c\">\u4e09\u3001SPI \u7bc7&#xff08;P1\u2013P17&#xff09;<\/span><\/h3>\n<p><span style=\"color:#b95514\">P1. SPI \u56db\u6839\u7ebf\u5404\u5e72\u4ec0\u4e48&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">SCK&#xff08;\u4e3b\u673a\u7ed9\u65f6\u949f&#xff09;\u3001MOSI&#xff08;\u4e3b\u673a\u51fa\u4ece\u673a\u5165&#xff09;\u3001<\/span><\/li>\n<li><span style=\"color:#0d0016\">MISO&#xff08;\u4ece\u673a\u51fa\u4e3b\u673a\u5165&#xff09;\u3001CS&#xff08;\u7247\u9009&#xff0c;\u4f4e\u6709\u6548&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u5168\u53cc\u5de5\u3001\u540c\u6b65&#xff1b;\u591a\u4ece\u673a\u9760 CS \u533a\u5206&#xff0c;\u65e0\u9700\u4e0a\u62c9\u7535\u963b&#xff08;\u63a8\u633d\u9a71\u52a8&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P2. \u56db\u79cd\u6a21\u5f0f&#xff08;CPOL\/CPHA&#xff09;&#xff1f;Flash \u5e38\u7528\u54ea\u4e2a&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">CPOL&#xff1a;\u7a7a\u95f2\u65f6\u949f\u7535\u5e73&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">CPHA&#xff1a;\u91c7\u6837\u6cbf&#xff08;1&#061;\u7b2c\u4e00\u4e2a\u6cbf&#xff0c;0&#061;\u7b2c\u4e8c\u4e2a\u6cbf&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">MODE0&#xff08;CPOL&#061;0,CPHA&#061;0&#xff09;\u548c MODE3&#xff08;CPOL&#061;1,CPHA&#061;1&#xff09;&#xff1a;\u90fd\u662f\u7b2c\u4e00\u4e2a\u6cbf\u91c7\u6837&#xff0c;\u53ea\u5dee\u7a7a\u95f2\u7535\u5e73&#xff0c;Flash \u4e24\u8005\u90fd\u517c\u5bb9\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u91c7\u6837\u70b9\u9519\u4e86&#xff08;MODE1\/2&#xff09;\u2192 \u4e00\u5b9a\u4e71\u7801\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P3. \u5168\u53cc\u5de5\u610f\u5473\u7740\u4ec0\u4e48&#xff1f;\u54d1\u5b57\u8282\u6280\u5de7&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u53d1 1 \u5b57\u8282\u7684\u540c\u65f6\u6536 1 \u5b57\u8282&#xff08;\u79fb\u4f4d\u5bc4\u5b58\u5668\u8fdb\u4e00\u51fa&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u60f3\u8bfb\u4ece\u673a \u2192 \u4e3b\u673a\u53d1 0xFF \u54d1\u5b57\u8282\u63a8\u65f6\u949f&#xff1b;\u53ea\u53d1\u4e0d\u6536\u4e5f\u8981\u5904\u7406 RXNE&#xff0c;\u5426\u5219\u6ea2\u51fa\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P4. CS \u7247\u9009\u65f6\u5e8f\u6ce8\u610f&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u5148\u62c9\u4f4e CS \u518d\u53d1\u6570\u636e&#xff0c;\u53d1\u5b8c\u7b49 BSY \u6e05\u518d\u62c9\u9ad8&#xff0c;\u5426\u5219\u5c3e\u5b57\u8282\u6b8b\u7f3a\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P5. \u963b\u585e\u5f0f HAL \u6d41\u7a0b &#043; \u4e3a\u4ec0\u4e48\u7b49 BSY&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">HAL_SPI_TransmitReceive&#xff1a;\u5199 DR \u2192 \u7b49 RXNE \u6536 \u2192 \u5168\u90e8\u53d1\u5b8c \u2192 \u7b49 BSY \u6e05&#xff08;\u79fb\u4f4d\u5bc4\u5b58\u5668\u79fb\u5b8c&#xff09;\u2192 \u8fd4\u56de\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u540c\u4e32\u53e3 TC \u7684\u9053\u7406&#xff1a;DR \u7a7a \u2260 \u53d1\u5b8c\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P6. SPI Flash \u547d\u4ee4\u8868&#xff08;\u5fc5\u80cc&#xff09;<\/span><\/p>\n<table>\n<tr><span style=\"color:#0d0016\">\u547d\u4ee4<\/span><span style=\"color:#0d0016\">\u7801<\/span><span style=\"color:#0d0016\">\u8bf4\u660e<\/span><\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#0d0016\">\u8bfb ID<\/span><\/td>\n<td><span style=\"color:#0d0016\">0x9F<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u8fd4\u56de JEDEC ID<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u5199\u4f7f\u80fd<\/span><\/td>\n<td><span style=\"color:#0d0016\">0x06<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u5199\/\u64e6\u9664\u524d\u5fc5\u987b\u53d1&#xff08;WEL \u81ea\u52a8\u6e05&#xff09;<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u8bfb\u72b6\u6001<\/span><\/td>\n<td><span style=\"color:#0d0016\">0x05<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u8f6e\u8be2 WIP \u5fd9\u6807\u5fd7<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u8bfb\u6570\u636e<\/span><\/td>\n<td><span style=\"color:#0d0016\">0x03<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u4efb\u610f\u5730\u5740\u8fde\u7eed\u8bfb<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u9875\u7f16\u7a0b<\/span><\/td>\n<td><span style=\"color:#0d0016\">0x02<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u4e00\u9875 256 \u5b57\u8282&#xff0c;\u8de8\u9875\u4f1a\u56de\u7ed5<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u6247\u533a\u64e6\u9664<\/span><\/td>\n<td><span style=\"color:#0d0016\">0x20<\/span><\/td>\n<td><span style=\"color:#0d0016\">4KB \u7c92\u5ea6&#xff0c;\u5199\u524d\u5fc5\u987b\u64e6<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<p><span style=\"color:#b95514\">P7. \u4e3a\u4ec0\u4e48\u5199\u4e4b\u524d\u5fc5\u987b\u5148\u64e6\u9664&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">Flash \u7f16\u7a0b\u53ea\u80fd\u628a\u4f4d 1\u21920&#xff1b;\u64e6\u9664\u628a\u6240\u6709\u4f4d\u6062\u590d\u4e3a 1 \u540e\u624d\u80fd\u518d\u7f16\u7a0b\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P8. \u8de8\u9875\u5199\u600e\u4e48\u5904\u7406&#xff1f;&#xff08;\u624b\u6495&#xff09;<\/span><\/p>\n<p>while (len) {<br \/>\n    Flash_WriteEnable();<br \/>\n    uint32_t page_left &#061; PAGE_SIZE &#8211; (addr % PAGE_SIZE);   \/\/ \u672c\u9875\u5269\u4f59<br \/>\n    uint32_t chunk &#061; (len &lt; page_left) ? len : page_left;  \/\/ \u6700\u591a\u5199\u5230\u9875\u5c3e<br \/>\n    \/\/ \u53d1 0x02 &#043; 24 \u4f4d\u5730\u5740 &#043; chunk \u5b57\u8282<br \/>\n    Flash_WaitBusy();                                       \/\/ \u8f6e\u8be2 WIP<br \/>\n    addr &#043;&#061; chunk; data &#043;&#061; chunk; len -&#061; chunk;<br \/>\n}<\/p>\n<hr \/>\n<p><span style=\"color:#b95514\">P9. \u8bfb ID \u65f6\u5e8f\u624b\u6495<\/span><\/p>\n<p>SPI_CS_LOW();<br \/>\nSPI_SendByte(0x9F);<br \/>\nid[0] &#061; SPI_SendByte(0xFF);   \/\/ \u54d1\u5b57\u8282\u63a8\u65f6\u949f&#xff0c;\u8bfb\u56de<br \/>\nid[1] &#061; SPI_SendByte(0xFF);<br \/>\nid[2] &#061; SPI_SendByte(0xFF);<br \/>\nSPI_CS_HIGH();<\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u8bfb\u5230\u5168 0xFF \u2192 CS \u6ca1\u9009\u4e2d \/ MISO \u60ac\u7a7a \/ \u547d\u4ee4\u4e0d\u652f\u6301\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P10. \u786c\u4ef6 NSS vs \u8f6f\u4ef6 CS&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u786c\u4ef6 NSS \u65f6\u5e8f\u53d7\u5916\u8bbe\u72b6\u6001\u673a\u7ea6\u675f\u3001\u591a\u4ece\u673a\u5207\u6362\u9ebb\u70e6&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8f6f\u4ef6 CS \u4efb\u610f GPIO \u624b\u52a8\u63a7\u5236&#xff0c;\u5de5\u7a0b\u4e0a 90% \u7528\u5b83\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P11. SPI DMA \u600e\u4e48\u914d&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u5927\u5757\u6570\u636e&#xff08;Flash \u9875\u7f16\u7a0b\u3001\u5237\u5c4f&#xff09;\u5fc5\u987b DMA&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u5168\u53cc\u5de5\u540c\u4f20\u7528 HAL_SPI_TransmitReceive_DMA\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u5c0f\u6570\u636e\u8f6e\u8be2\u3001\u4e2d\u91cf\u4e2d\u65ad\u3001\u5927\u5757 DMA&#xff08;\u548c\u4e32\u53e3\u540c\u4e00\u5957\u9009\u578b\u903b\u8f91&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P12. SPI \u4e2d\u65ad\u6a21\u5f0f&#xff08;10.3&#xff09;\u600e\u4e48\u5de5\u4f5c&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">TXE \u7a7a\u4e2d\u65ad\u53d1\u4e0b\u4e00\u5b57\u8282\u3001RXNE \u6ee1\u4e2d\u65ad\u6536\u5b57\u8282&#xff0c;\u9010\u5b57\u8282\u63a8\u8fdb&#xff1b;\u6bd4\u963b\u585e\u7701 CPU&#xff0c;\u6bd4 DMA \u4ee3\u7801\u7b80\u5355\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P13. SPI \u6536\u4e71\u7801\u6392\u67e5\u987a\u5e8f&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u6a21\u5f0f&#xff08;CPOL\/CPHA&#xff09;\u5339\u914d \u2192 MISO\/MOSI \u63a5\u53cd \u2192 CS \u65f6\u5e8f \u2192 \u65f6\u949f\u9891\u7387\u8d85\u4ece\u673a\u4e0a\u9650 \u2192 \u8d70\u7ebf\u5e72\u6270\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P14. SPI \u65f6\u949f\u9891\u7387\u80fd\u968f\u4fbf\u8bbe&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u53d7\u4ece\u673a\u4e0a\u9650&#xff08;W25Q \u652f\u6301\u5f88\u9ad8&#xff09;\u548c\u4e3b\u673a\u5916\u8bbe\u9650\u5236&#xff08;F1 SPI1 \u7531 APB2&#061;72MHz \u5206\u9891&#xff09;&#xff1b;\u9ad8\u901f\u6ce8\u610f\u8d70\u7ebf\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P15. \u624b\u6495&#xff1a;SPI \u4e3b\u673a\u6536\u53d1\u4e00\u5b57\u8282<\/span><\/p>\n<p>uint8_t SPI_SendByte(uint8_t byte) {<br \/>\n    SPI1-&gt;DR &#061; byte;<br \/>\n    while (!(SPI1-&gt;SR &amp; SPI_SR_RXNE));   \/\/ \u5168\u53cc\u5de5\u5fc5\u6709\u56de\u5e94<br \/>\n    return SPI1-&gt;DR;<br \/>\n}<\/p>\n<p><span style=\"color:#b95514\">P16. SPI vs I2C \u5bf9\u6bd4\u8868<\/span><\/p>\n<table>\n<tr><span style=\"color:#0d0016\">\u7ef4\u5ea6<\/span><span style=\"color:#0d0016\">SPI<\/span><span style=\"color:#0d0016\">I2C<\/span><\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#0d0016\">\u7ebf\u6570<\/span><\/td>\n<td><span style=\"color:#0d0016\">4&#xff08;\u542b CS&#xff09;<\/span><\/td>\n<td><span style=\"color:#0d0016\">2<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u53cc\u5de5<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u5168\u53cc\u5de5<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u534a\u53cc\u5de5<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u901f\u7387<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u6570\u5341 MHz<\/span><\/td>\n<td><span style=\"color:#0d0016\">100k~1M<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u5bfb\u5740<\/span><\/td>\n<td><span style=\"color:#0d0016\">CS \u7247\u9009<\/span><\/td>\n<td><span style=\"color:#0d0016\">7\/10 \u4f4d\u5730\u5740<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u591a\u4e3b\u673a<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u4e0d\u652f\u6301<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u652f\u6301\u4ef2\u88c1<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u9a71\u52a8<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u63a8\u633d<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u5f00\u6f0f&#043;\u4e0a\u62c9<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u5178\u578b<\/span><\/td>\n<td><span style=\"color:#0d0016\">Flash\/SD\/\u5c4f\/ADC<\/span><\/td>\n<td><span style=\"color:#0d0016\">EEPROM\/\u4f20\u611f\u5668\/RTC<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<p><span style=\"color:#b95514\">P17. SPI \u9ad8\u9891\u8ffd\u95ee\u901f\u7b54<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">SPI \u6709\u6ce2\u7279\u7387\u8bef\u5dee\u95ee\u9898\u5417&#xff1f;\u2192 \u6ca1\u6709&#xff0c;\u540c\u6b65\u65f6\u949f\u7531\u4e3b\u673a\u7ed9\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u4ece\u673a\u591a\u600e\u4e48\u63a5&#xff1f;\u2192 \u5171\u4eab SCK\/MOSI\/MISO&#xff0c;\u5404\u63a5\u4e00\u6839 CS\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u53d1 0xFF \u662f\u5e72\u561b&#xff1f;\u2192 \u63d0\u4f9b\u65f6\u949f\u63a8\u6570\u636e&#xff08;\u8bfb\u64cd\u4f5c&#xff09;<\/span><span style=\"color:#0d0016\">\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<h3><span style=\"color:#1a439c\">\u56db\u3001\u4e09\u534f\u8bae\u7efc\u5408\u5bf9\u6bd4\u9898&#xff08;C1\u2013C6&#xff09;<\/span><\/h3>\n<p><span style=\"color:#b95514\">C1. \u5b8c\u6574\u5bf9\u6bd4\u8868&#xff08;\u7ec8\u6781\u7248&#xff09;<\/span><\/p>\n<table>\n<tr><span style=\"color:#0d0016\">\u7ef4\u5ea6<\/span><span style=\"color:#0d0016\">USART<\/span><span style=\"color:#0d0016\">I2C<\/span><span style=\"color:#0d0016\">SPI<\/span><\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#0d0016\">\u7ebf\u6570<\/span><\/td>\n<td style=\"width:207px\"><span style=\"color:#0d0016\">2~3<\/span><\/td>\n<td style=\"width:201px\"><span style=\"color:#0d0016\">2<\/span><\/td>\n<td><span style=\"color:#0d0016\">4<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u53cc\u5de5<\/span><\/td>\n<td style=\"width:207px\"><span style=\"color:#0d0016\">\u5168<\/span><\/td>\n<td style=\"width:201px\"><span style=\"color:#0d0016\">\u534a<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u5168<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u540c\u6b65\u6027<\/span><\/td>\n<td style=\"width:207px\"><span style=\"color:#0d0016\">\u5f02\u6b65&#xff08;\u5404\u81ea\u65f6\u949f&#xff09;<\/span><\/td>\n<td style=\"width:201px\"><span style=\"color:#0d0016\">\u540c\u6b65<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u540c\u6b65<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u901f\u7387<\/span><\/td>\n<td style=\"width:207px\"><span style=\"color:#0d0016\">\u5e38\u89c1 \u2264115200&#xff0c;\u4e0a\u9650 fck\/16<\/span><\/td>\n<td style=\"width:201px\"><span style=\"color:#0d0016\">100k~1M<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u6570\u5341 MHz<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u5bfb\u5740<\/span><\/td>\n<td style=\"width:207px\"><span style=\"color:#0d0016\">\u65e0<\/span><\/td>\n<td style=\"width:201px\"><span style=\"color:#0d0016\">\u5730\u5740\u5e27<\/span><\/td>\n<td><span style=\"color:#0d0016\">CS \u7247\u9009<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u9a71\u52a8<\/span><\/td>\n<td style=\"width:207px\"><span style=\"color:#0d0016\">TTL \u63a8\u633d\/RS232\/485<\/span><\/td>\n<td style=\"width:201px\"><span style=\"color:#0d0016\">\u5f00\u6f0f&#043;\u4e0a\u62c9<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u63a8\u633d<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u591a\u4e3b\u673a<\/span><\/td>\n<td style=\"width:207px\"><span style=\"color:#0d0016\">\u65e0<\/span><\/td>\n<td style=\"width:201px\"><span style=\"color:#0d0016\">\u6709&#xff08;\u4ef2\u88c1&#xff09;<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u65e0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u5178\u578b\u5668\u4ef6<\/span><\/td>\n<td style=\"width:207px\"><span style=\"color:#0d0016\">GPS\/\u84dd\u7259\/\u4e0a\u4f4d\u673a<\/span><\/td>\n<td style=\"width:201px\"><span style=\"color:#0d0016\">EEPROM\/\u4f20\u611f\u5668\/RTC<\/span><\/td>\n<td><span style=\"color:#0d0016\">Flash\/SD\/\u5c4f\/ADC<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<p><span style=\"color:#b95514\">C2. \u9009\u578b\u9898&#xff1a;\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668\u3001GPS\u3001SPI Flash\u3001RTC\u3001\u5c4f\u5e55\u5206\u522b\u7528\u4ec0\u4e48&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u6e29\u6e7f\u5ea6&#xff08;SHT30 \u7b49 I2C&#xff09;\u3001GPS&#xff08;USART \u8f93\u51fa NMEA&#xff09;\u3001Flash&#xff08;SPI \u9ad8\u901f\u5927\u5757&#xff09;\u3001RTC&#xff08;I2C&#xff0c;\u5982 DS3231&#xff09;\u3001\u5c4f\u5e55&#xff08;SPI \u5237\u5c4f\u5feb&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">C3. \u540c\u6b65 vs \u5f02\u6b65\u7684\u6838\u5fc3\u533a\u522b&#xff08;\u4e3a\u4ec0\u4e48\u53ea\u6709 USART \u6709&#034;\u6ce2\u7279\u7387\u5bf9\u9f50&#034;\u95ee\u9898&#xff09;&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u5f02\u6b65\u6ca1\u6709\u65f6\u949f\u7ebf&#xff0c;\u53cc\u65b9\u5404\u81ea\u8ba1\u65f6 \u2192 \u5fc5\u987b\u7ea6\u5b9a\u5e76\u6821\u51c6\u6ce2\u7279\u7387&#xff0c;\u8bef\u5dee &lt;2% \u624d\u7a33&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u540c\u6b65\u7531\u4e3b\u673a\u63d0\u4f9b\u65f6\u949f&#xff0c;\u4ece\u673a\u8ddf\u7740\u6cbf\u8d70 \u2192 \u4e0d\u5b58\u5728\u6ce2\u7279\u7387\u8bef\u5dee&#xff0c;\u4f46\u4e3b\u673a\u65f6\u949f\u4e0a\u9650\u51b3\u5b9a\u901f\u7387\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">C4. \u7efc\u5408\u8bbe\u8ba1\u9898&#xff1a;\u4e00\u4e2a\u91c7\u96c6\u7cfb\u7edf&#xff08;SPI Flash \u5b58\u6570\u636e &#043; I2C \u8bfb\u4f20\u611f\u5668 &#043; USART \u4e0a\u62a5&#xff09;&#xff0c;\u4e2d\u65ad\u4f18\u5148\u7ea7\u600e\u4e48\u6392&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u6570\u636e\u6613\u4e22\u4f18\u5148&#xff1a;USART \u63a5\u6536\/DMA \u5b8c\u6210&#xff08;\u9ad8&#xff09;\u2192 I2C \u4e8b\u4ef6&#xff08;\u4e2d&#xff09;\u2192 SPI \u4f20\u8f93\u5b8c\u6210&#xff08;\u4e2d&#xff09;\u2192 \u4e1a\u52a1\u5904\u7406&#xff08;\u4f4e&#xff09;&#xff1b;\u5171\u7528\u7f13\u51b2\u5fc5\u987b\u52a0\u73af\u5f62\u961f\u5217 &#043; volatile\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">C5. \u4e00\u53e5\u8bdd\u8bf4\u51fa\u6bcf\u4e2a\u534f\u8bae\u7684&#034;\u81f4\u547d\u5f31\u70b9&#034;&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">USART&#xff1a;\u5f02\u6b65\u901f\u7387\u53d7\u6ce2\u7279\u7387\u8bef\u5dee\/APB \u65f6\u949f\u9650\u5236&#xff0c;\u70b9\u5bf9\u70b9\u4e0d\u80fd\u6302\u591a\u8bbe\u5907&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">I2C&#xff1a;\u534a\u53cc\u5de5 &#043; \u5f00\u6f0f\u901f\u7387\u4e0a\u4e0d\u53bb&#xff0c;\u603b\u7ebf\u5361\u6b7b\u8981\u6062\u590d&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">SPI&#xff1a;\u7ebf\u591a\u3001\u65e0\u5730\u5740&#xff08;\u4ece\u673a\u591a\u8981 CS \u5f15\u811a\u591a&#xff09;\u3001\u4e0d\u80fd\u591a\u4e3b\u673a\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">C6. \u624b\u6495\u7efc\u5408&#xff1a;\u4e00\u4e2a\u7cfb\u7edf\u91cc\u4e09\u534f\u8bae\u5404\u81ea\u521d\u59cb\u5316\u987a\u5e8f&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u5148\u65f6\u949f&#xff08;RCC&#xff09;\u2192 GPIO \u590d\u7528\/\u5f00\u6f0f\u914d\u7f6e \u2192 \u5404\u81ea\u5916\u8bbe\u521d\u59cb\u5316&#xff08;USART \u6ce2\u7279\u7387\u3001I2C \u65f6\u5e8f\u3001SPI \u6a21\u5f0f\/\u5206\u9891&#xff09;\u2192 \u4e2d\u65ad\u4f18\u5148\u7ea7 \u2192 \u4f7f\u80fd&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u987a\u5e8f\u9519\u4e86&#xff1a;\u6ca1\u5f00\u65f6\u949f\u5148\u914d\u5916\u8bbe &#061; \u5bc4\u5b58\u5668\u5199\u5165\u65e0\u6548\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<h3><span style=\"color:#1a439c\">\u4e09\u5927\u534f\u8bae\u901f\u8bb0\u5361<\/span><\/h3>\n<table>\n<tr><span style=\"color:#0d0016\">\u8003\u70b9<\/span><span style=\"color:#0d0016\">USART<\/span><span style=\"color:#0d0016\">I2C<\/span><span style=\"color:#0d0016\">SPI<\/span><\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#0d0016\">\u4e00\u53e5\u8bdd\u672c\u8d28<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u5f02\u6b65\u70b9\u5bf9\u70b9<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u5f00\u6f0f\u603b\u7ebf &#043; \u5730\u5740<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u540c\u6b65\u5168\u53cc\u5de5 &#043; \u7247\u9009<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u6700\u5e38\u8003\u8ba1\u7b97<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u6ce2\u7279\u7387\u516c\u5f0f\/\u8bef\u5dee<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u4e0a\u62c9\u53d6\u503c<\/span><\/td>\n<td><span style=\"color:#0d0016\">CPOL\/CPHA \u6a21\u5f0f<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u6700\u5e38\u8003\u4ee3\u7801<\/span><\/td>\n<td><span style=\"color:#0d0016\">IDLE&#043;DMA \u6536<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u6a21\u62df I2C \u6536\u53d1<\/span><\/td>\n<td><span style=\"color:#0d0016\">Flash \u8de8\u9875\u5199<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u6700\u5e38\u8003\u9677\u9631<\/span><\/td>\n<td><span style=\"color:#0d0016\">TXE\u2260TC<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u8bfb\u8981\u91cd\u590d\u8d77\u59cb&#043;\u6700\u540e NACK<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u53d1\u5b8c\u7b49 BSY\u3001\u5148\u64e6\u540e\u5199<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u6700\u9ad8\u9891\u8ffd\u95ee<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u8f6e\u8be2\/\u4e2d\u65ad\/DMA<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u603b\u7ebf\u5361\u6b7b\u6062\u590d<\/span><\/td>\n<td><span style=\"color:#0d0016\">SPI vs I2C \u9009\u578b<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2><span style=\"color:#a2e043\"><span style=\"background-color:#7b7f82\">\u00a0 STM32 \u9762\u8bd5\u6df1\u6c34\u533a\u9898\u5e93&#xff08;\u4ee3\u7801\u7ea7 \u00b7 \u539f\u7406\u7ea7 \u00b7 \u8ba1\u7b97\u7ea7 \u00b7 31 \u9898&#xff09;<\/span><\/span><\/h2>\n<h3><span style=\"color:#1a439c\">\u6df1\u6316\u4e00 \u00b7 \u4e2d\u65ad\/\u5f02\u5e38\u5e95\u5c42&#xff08;D1\u2013D8&#xff09;<\/span><\/h3>\n<p><span style=\"color:#b95514\">D1. \u786c\u4ef6\u538b\u6808\u5230\u5e95\u538b\u4e86\u54ea\u4e9b\u5bc4\u5b58\u5668&#xff1f;\u987a\u5e8f\u5982\u4f55&#xff1f;&#xff08;\u73b0\u573a\u8fd8\u539f\u9898&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u8fdb\u5165\u5f02\u5e38\u65f6\u786c\u4ef6\u81ea\u52a8\u538b\u5165 8 \u4e2a 32 \u4f4d\u5bc4\u5b58\u5668&#xff08;SP \u51cf 32 \u5b57\u8282&#xff09;&#xff1a;xPSR\u3001PC\u3001LR\u3001R12\u3001R3\u3001R2\u3001R1\u3001R0\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u538b\u6808\u987a\u5e8f\u662f&#034;\u5148\u5165\u9ad8\u5730\u5740\u518d\u5165\u4f4e\u5730\u5740&#034;&#xff0c;PC \u91cc\u4fdd\u5b58\u7684\u662f\u88ab\u4e2d\u65ad\u6307\u4ee4\u7684\u4e0b\u4e00\u6761&#xff08;\u8fd4\u56de\u5730\u5740&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">M4F&#xff08;\u5e26 FPU&#xff09;&#xff1a;\u9ed8\u8ba4\u60f0\u6027\u538b\u6808&#xff08;Lazy Stacking&#xff09;\u2014\u2014\u53ea\u6709 ISR \u771f\u7528\u4e86\u6d6e\u70b9\u5bc4\u5b58\u5668&#xff0c;\u624d\u538b FPSCR &#043; S0~S15&#xff0c;\u7701\u6389\u5927\u90e8\u5206\u4e2d\u65ad\u7684\u65f6\u95f4\u5f00\u9500\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4e3a\u4ec0\u4e48 R4~R11 \u4e0d\u538b&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u7531\u7f16\u8bd1\u5668\u5728 ISR \u5f00\u5934\u538b&#xff08;\u8f6f\u538b\u6808&#xff09;&#xff0c;\u4e14\u53ea\u6709\u7528\u5230\u7684\u624d\u538b&#xff0c;\u8282\u7701\u65f6\u95f4\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">D2. EXC_RETURN \u4e09\u4e2a\u503c\u7684\u5b8c\u6574\u542b\u4e49&#xff1f;\u8c03\u8bd5\u65f6\u600e\u4e48\u7528&#xff1f;<\/span><\/p>\n<table>\n<tr><span style=\"color:#0d0016\">\u503c<\/span><span style=\"color:#0d0016\">\u542b\u4e49<\/span><\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#0d0016\">0xFFFFFFF1<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u8fd4\u56de Handler \u6a21\u5f0f&#xff08;\u5d4c\u5957\u4e2d\u65ad\u8fd4\u56de&#xff09;<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">0xFFFFFFF9<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u8fd4\u56de\u7ebf\u7a0b\u6a21\u5f0f &#043; \u4e3b\u6808 MSP&#xff08;\u88f8\u673a\u4e3b\u7a0b\u5e8f&#xff09;<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">0xFFFFFFFD<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u8fd4\u56de\u7ebf\u7a0b\u6a21\u5f0f &#043; \u8fdb\u7a0b\u6808 PSP&#xff08;RTOS \u4efb\u52a1&#xff09;<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li><span style=\"color:#0d0016\">\u7528\u6cd5&#xff1a;\u65ad\u70b9\u8fdb HardFault \u540e\u770b LR&#xff0c;0xFFFFFFFD \u2192 \u6545\u969c\u53d1\u751f\u5728\u4efb\u52a1\u6808&#xff0c;\u591a\u534a\u662f RTOS \u4efb\u52a1\u6808\u6ea2\u51fa\/\u8d8a\u754c&#xff1b;0xFFFFFFF9 \u2192 \u4e3b\u6808&#xff08;\u88f8\u673a\u6808\u6ea2\u51fa&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4e3a\u4ec0\u4e48\u8fd9\u4e9b\u503c\u4ee5 0xFFFFFFF \u5f00\u5934&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u9ad8 28 \u4f4d\u5168 1 \u662f Cortex-M \u4fdd\u7559\u7684\u7279\u6b8a\u5730\u5740\u6bb5&#xff0c;CPU \u8bc6\u522b\u4e3a&#034;\u5f02\u5e38\u8fd4\u56de\u6307\u4ee4&#034;\u800c\u975e\u666e\u901a\u8df3\u8f6c\u5730\u5740\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">D3. FreeRTOS \u4e0a\u4e0b\u6587\u5207\u6362\u7684\u6c47\u7f16\u7ea7\u601d\u8def&#xff1f;&#xff08;\u5fc5\u8003\u52a0\u5206\u9898&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">SysTick ISR&#xff1a;\u5224\u5b9a\u9700\u8981\u5207\u6362 \u2192 \u89e6\u53d1 PendSV&#xff08;\u6302\u8d77&#xff0c;\u4e0d\u7acb\u5373\u6267\u884c&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">PendSV ISR&#xff08;vPortSVCHandler\/xPortPendSVHandler&#xff09;&#xff1a;<\/span>\n<li><span style=\"color:#0d0016\">\u5173\u4e2d\u65ad&#xff08;BASEPRI\/PRIMASK&#xff0c;\u9632\u5207\u6362\u8fc7\u7a0b\u88ab\u6253\u65ad&#xff09;&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8f6f\u4ef6\u4fdd\u5b58 R4~R11 \u5230\u5f53\u524d\u4efb\u52a1\u6808&#xff08;R0~R3\/PC\/LR\/xPSR \u5df2\u5728\u8fdb\u5f02\u5e38\u65f6\u88ab\u786c\u4ef6\u538b\u6808&#xff09;&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u66f4\u65b0\u5f53\u524d\u4efb\u52a1\u63a7\u5236\u5757\u7684 SP \u6307\u9488&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u53d6\u65b0\u4efb\u52a1 SP&#xff0c;PSP &#061; \u65b0SP&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u4ece\u65b0\u4efb\u52a1\u6808\u6062\u590d R4~R11&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u5f00\u4e2d\u65ad&#xff0c;BX LR&#xff08;0xFFFFFFFD \u2192 \u4ee5 PSP \u51fa\u6808\u6062\u590d\u65b0\u4efb\u52a1\u73b0\u573a&#xff09;\u3002<\/span><\/li>\n<\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4e3a\u4ec0\u4e48 R4R11 \u7531\u8f6f\u4ef6\u4fdd\u5b58\u800c R0R3 \u4e0d\u7528&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 R0R3\/PC\/LR\/xPSR \u786c\u4ef6\u5df2\u7ecf\u538b\u6808\u4e86&#xff0c;\u53ea\u5dee R4R11 \u8fd9 8 \u4e2a&#034;callee-saved&#034;&#xff0c;\u8f6f\u4ef6\u8865\u538b\u5373\u53ef\u2014\u2014\u8fd9\u5c31\u662f\u786c\u4ef6\u538b\u6808\u8bbe\u8ba1\u7701\u8f6f\u4ef6\u4ee3\u7801\u7684\u5173\u952e\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">D4. HardFault \u5b9e\u6218&#xff1a;\u6570\u7ec4\u8d8a\u754c\u5199\u574f\u4e86\u76f8\u90bb\u53d8\u91cf&#xff0c;\u600e\u4e48\u4e00\u6b65\u6b65\u5b9a\u4f4d&#xff1f;&#xff08;\u5b9e\u64cd\u9898&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u6b65\u9aa4&#xff1a;<\/span>\n<li><span style=\"color:#0d0016\">\u65ad\u70b9\u505c\u8fdb HardFault_Handler&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u770b LR \u7684 EXC_RETURN \u5b9a MSP\/PSP&#xff08;\u88f8\u673a\u8fd8\u662f\u4efb\u52a1&#xff09;&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u627e\u5230\u5bf9\u5e94\u6808\u6307\u9488&#xff0c;\u8bfb\u51fa\u538b\u6808\u533a\u7684 PC&#xff08;\u51fa\u95ee\u9898\u6307\u4ee4\u7684\u4e0b\u4e00\u6761&#xff09;\u548c R0~R3&#xff08;\u5f53\u65f6\u53c2\u6570&#xff09;&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u5728\u53cd\u6c47\u7f16\u7a97\u53e3\u5b9a\u4f4d PC \u6307\u4ee4&#xff0c;\u770b\u5b83\u5199\/\u8bfb\u4e86\u54ea\u4e2a\u5730\u5740&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u5bf9\u7167\u6545\u969c\u72b6\u6001\u5bc4\u5b58\u5668&#xff1a;CFSR \u7684 MMFSR\/BFSR\/UFSR \u5206\u522b\u6307\u5411\u5185\u5b58\u7ba1\u7406\/\u603b\u7ebf\/\u7528\u6cd5\u9519\u8bef&#xff0c;BFAR\/MMFAR \u7ed9\u51fa\u6545\u969c\u5730\u5740\u2014\u2014\u5730\u5740\u660e\u663e\u5f02\u5e38&#xff08;\u5982 0xDEADBEEF\u3001\u8d8a\u754c\u6570\u7ec4\u5c3e&#xff09;\u5c31\u9501\u5b9a\u6839\u56e0&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u56de\u4ee3\u7801\u67e5\u5bf9\u5e94\u6570\u7ec4\u4e0b\u6807\/\u6307\u9488\u8fd0\u7b97\u3002<\/span><\/li>\n<\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u6808\u6ea2\u51fa\u600e\u4e48\u4e3b\u52a8\u68c0\u6d4b&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u542f\u52a8\u65f6\u628a\u6808\u533a\u586b\u6ee1 0xCC&#xff0c;\u5468\u671f\u6027\u68c0\u67e5\u6808\u5e95\u6807\u8bb0\u662f\u5426\u88ab\u51b2\u6389&#xff1b;\u6216 RTOS \u4efb\u52a1\u6808\u540c\u6837\u624b\u6cd5&#xff1b;FreeRTOS \u6709 configCHECK_FOR_STACK_OVERFLOW \u94a9\u5b50\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">D5. \u4e34\u754c\u533a\u9898&#xff1a;\u4e3b\u5faa\u73af counter&#043;&#043;\u3001\u4e2d\u65ad\u91cc\u8bfb counter&#xff0c;\u4e0d\u52a0\u4fdd\u62a4\u4f1a\u600e\u6837&#xff1f;\u600e\u4e48\u4fee&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u4f1a\u600e\u6837&#xff1a;counter&#043;&#043; \u662f&#034;\u8bfb-\u52a0-\u5199&#034;\u4e09\u6761\u6307\u4ee4&#xff0c;\u4e2d\u65ad\u6b63\u597d\u6253\u5728\u4e2d\u95f4 \u2192 \u8bfb\u5230\u9519\u4f4d\u503c&#xff08;\u8001\u503c\/\u4e2d\u95f4\u503c&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u4fee&#xff1a;volatile&#xff08;\u4fdd\u8bc1\u4e0d\u7f13\u5b58&#xff09;&#043; \u8bfb\u65f6\u5173\u4e2d\u65ad&#xff08;\u4fdd\u8bc1\u8bfb-\u6539\u5199\u539f\u5b50&#xff09;&#xff1a;<\/span><\/li>\n<\/ul>\n<p>volatile uint32_t counter;<br \/>\nuint32_t safe_read(void) {<br \/>\n    __disable_irq();<br \/>\n    uint32_t v &#061; counter;<br \/>\n    __enable_irq();<br \/>\n    return v;<br \/>\n}<\/p>\n<ul>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4e3a\u4ec0\u4e48\u4f4d\u5e26\u6551\u4e0d\u4e86\u8ba1\u6570\u5668&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u4f4d\u5e26\u53ea\u5bf9\u5355\u4e2a bit \u539f\u5b50&#xff0c;32 \u4f4d\u8ba1\u6570\u5668\u662f\u591a bit \u8bfb\u6539\u5199&#xff0c;\u5173\u4e2d\u65ad\u624d\u662f\u6b63\u786e\u89e3\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">D6. \u4f4d\u5e26\u8ba1\u7b97\u9898&#xff1a;SRAM \u53d8\u91cf 0x20000000 \u7684 bit2&#xff0c;\u522b\u540d\u5730\u5740\u662f\u591a\u5c11&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u516c\u5f0f&#xff1a;\u522b\u540d\u5730\u5740 &#061; \u522b\u540d\u57fa\u5740 &#043; (\u76ee\u6807\u5730\u5740\u2212\u4f4d\u5e26\u57fa\u5740)\u00d732 &#043; bit\u00d74<\/span><\/li>\n<li><span style=\"color:#0d0016\">SRAM&#xff1a;0x2000 0000 \u2192 0x2200 0000&#xff1b;<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u4ee3\u5165&#xff1a;0x22000000 &#043; 0\u00d732 &#043; 2\u00d74 &#061; 0x22000008\u3002<\/span><\/li>\n<li><span style=\"color:#be191c\">\u8ffd\u95ee&#xff1a;\u5bf9 0x22000008 \u5199 1 \u7b49\u4ef7\u4e8e\u4ec0\u4e48&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u539f\u5b50\u5730\u628a 0x20000000 \u7684 bit2 \u7f6e 1&#xff0c;\u5355\u603b\u7ebf\u64cd\u4f5c&#xff0c;\u4e0d\u5173\u4e2d\u65ad\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">D7. SysTick \u8ba1\u7b97\u9898&#xff1a;72MHz \u4e0b 1ms \u8282\u62cd&#xff0c;LOAD \u586b\u591a\u5c11&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">LOAD &#061; \u65f6\u949f\/\u8282\u62cd\u9891\u7387 \u2212 1 &#061; 72000000\/1000 \u2212 1 &#061; 71999 &#061; 0x1193F\u3002<\/span><\/li>\n<li><span style=\"color:#be191c\">\u8ffd\u95ee&#xff1a;\u5982\u679c\u7cfb\u7edf\u5207\u5230 HSI 8MHz&#xff08;\u4e0d\u5206\u9891&#xff09;&#xff0c;\u91cd\u7b97&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 8000\u22121 &#061; 7999&#xff1b;\u5fd8\u4e86\u6539\u4f1a\u5bfc\u81f4\u8282\u62cd\u53d8\u5feb\/\u53d8\u6162&#xff08;\u65f6\u95f4\u5168\u9519&#xff09;&#xff0c;\u8fd9\u6b63\u662f R9 \u91cc&#034;HSE \u5931\u6548\u5207 HSI \u540e\u5b9a\u65f6\u5168\u4e71&#034;\u7684\u91cf\u5316\u6765\u6e90\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">D8. \u573a\u666f\u9898&#xff1a;A \u4e2d\u65ad(\u62a2\u53601) \u548c B \u4e2d\u65ad(\u62a2\u53601) \u540c\u65f6\u6765&#xff0c;\u8c01\u5148&#xff1f;\u5982\u679c A \u5148\u6267\u884c\u5b8c\u4e4b\u524d B \u53c8\u6765&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u62a2\u5360\u76f8\u540c \u2192 \u6bd4\u5b50\u4f18\u5148\u7ea7 \u2192 \u518d\u76f8\u540c \u2192 \u6bd4\u4e2d\u65ad\u53f7&#xff08;\u7f16\u53f7\u5c0f\u5148&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u62a2\u5360\u76f8\u540c\u4e0d\u80fd\u5d4c\u5957&#xff1a;B \u53ea\u80fd\u7b49 A \u6267\u884c\u5b8c&#xff1b;\u4f46\u82e5 B \u62a2\u5360\u66f4\u9ad8&#xff08;\u5982 0&#xff09;&#xff0c;\u4f1a\u7acb\u5373\u6253\u65ad A&#xff08;\u5d4c\u5957&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8ffd\u95ee&#xff1a;\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48&#034;\u62a2\u5360\u4f18\u5148\u7ea7\u51b3\u5b9a\u5b9e\u65f6\u4e0a\u9650&#xff0c;\u5b50\u4f18\u5148\u7ea7\u53ea\u51b3\u5b9a\u6392\u961f\u987a\u5e8f&#034;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<h3><span style=\"color:#1a439c\">\u6df1\u6316\u4e8c \u00b7 USART \u4ee3\u7801\u7ea7&#xff08;U6\u2013U11&#xff09;<\/span><\/h3>\n<p><span style=\"color:#b95514\">U6. IDLE &#043; DMA \u4e0d\u5b9a\u957f\u63a5\u6536&#xff1a;\u5b8c\u6574\u521d\u59cb\u5316 &#043; \u4e2d\u65ad\u4ee3\u7801&#xff08;\u624b\u6495\u9898&#xff09;<\/span><\/p>\n<p>\/\/ \u521d\u59cb\u5316&#xff1a;DMA1_Channel5 \u5faa\u73af\u6a21\u5f0f\u6536 USART1_RX<br \/>\nDMA_InitStructure.DMA_DIR &#061; DMA_DIR_PeripheralSRC;      \/\/ \u5916\u8bbe\u2192\u5185\u5b58<br \/>\nDMA_InitStructure.DMA_PeripheralBaseAddr &#061; (uint32_t)&amp;USART1-&gt;DR;<br \/>\nDMA_InitStructure.DMA_MemoryBaseAddr &#061; (uint32_t)rx_buf;<br \/>\nDMA_InitStructure.DMA_BufferSize &#061; RX_BUF_SIZE;<br \/>\nDMA_InitStructure.DMA_Mode &#061; DMA_Mode_Circular;         \/\/ \u5173\u952e&#xff1a;\u5faa\u73af<br \/>\nDMA_InitStructure.DMA_MemoryDataSize &#061; DMA_MemoryDataSize_Byte;<br \/>\nDMA_Init(DMA1_Channel5, &amp;DMA_InitStructure);<br \/>\nDMA_Cmd(DMA1_Channel5, ENABLE);<br \/>\nUSART_ITConfig(USART1, USART_IT_IDLE, ENABLE);          \/\/ \u7a7a\u95f2\u4e2d\u65ad<\/p>\n<p>void USART1_IRQHandler(void) {<br \/>\n    if (USART_GetITStatus(USART1, USART_IT_IDLE)) {<br \/>\n        USART1-&gt;SR; USART1-&gt;DR;                          \/\/ \u6e05 IDLE&#xff1a;\u8bfb SR&#043;DR<br \/>\n        uint16_t len &#061; RX_BUF_SIZE &#8211; DMA_GetCurrDataCounter(DMA1_Channel5);<br \/>\n        frame_ready &#061; 1;                                 \/\/ \u4e3b\u5faa\u73af\u6309 len \u89e3\u6790 rx_buf<br \/>\n        DMA_Cmd(DMA1_Channel5, DISABLE);                 \/\/ \u91cd\u7f6e\u524d\u5fc5\u987b\u5173 DMA<br \/>\n        DMA_SetCurrDataCounter(DMA1_Channel5, RX_BUF_SIZE);<br \/>\n        DMA_Cmd(DMA1_Channel5, ENABLE);<br \/>\n    }<br \/>\n}<\/p>\n<ul>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee 1&#xff1a;\u4e3a\u4ec0\u4e48\u91cd\u7f6e\u8ba1\u6570\u524d\u8981 DISABLE&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 CNDTR \u53ea\u80fd\u5728 DMA \u5173\u95ed\u65f6\u5199\u5165&#xff0c;\u5426\u5219\u5199\u5165\u65e0\u6548\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee 2&#xff1a;\u4e24\u5e27\u8fde\u53d1\u4f1a\u600e\u6837&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u7b2c\u4e00\u5e27 IDLE \u4e2d\u65ad\u540e\u7f13\u51b2\u533a\u8fd8\u6ca1\u88ab\u6d88\u8d39&#xff0c;\u7b2c\u4e8c\u5e27 DMA \u53c8\u5f00\u59cb\u8986\u76d6\u5199 \u2192 \u5fc5\u987b\u4fdd\u8bc1\u4e3b\u5faa\u73af\u6d88\u8d39\u901f\u5ea6 &gt; \u63a5\u6536\u901f\u5ea6&#xff0c;\u6216\u6362\u53cc\u7f13\u51b2\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U7. \u5927\u6570\u636e\u8fde\u7eed\u63a5\u6536\u600e\u4e48\u4e0d\u4e22&#xff1f;&#xff08;\u53cc\u7f13\u51b2 &#043; \u534a\u6ee1\u4e2d\u65ad\u65b9\u6848&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u4e24\u4e2a BUFSZ \u7f13\u51b2\u533a\u8f6e\u6362&#xff1a;DMA \u6536\u6ee1 A \u65f6&#xff08;\u4f20\u8f93\u5b8c\u6210\u4e2d\u65ad&#xff09;\u2192 \u7acb\u523b\u5207\u5230 B \u6536 \u2192 \u4e3b\u5faa\u73af\u6162\u6162\u6d88\u8d39 A&#xff1b;B \u6ee1\u518d\u5207\u56de\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u6216\u5355\u7f13\u51b2 &#043; \u534a\u6ee1\u4e2d\u65ad&#xff1a;\u7f13\u51b2\u524d\u534a\u6ee1\u65f6\u4e2d\u65ad\u901a\u77e5\u642c\u8d70\u524d\u534a&#xff0c;DMA \u7ee7\u7eed\u6536\u540e\u534a&#xff0c;\u642c\u5b8c\u518d\u7b49\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u8fd9\u672c\u8d28\u662f\u4ec0\u4e48&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u751f\u4ea7\u8005&#xff08;DMA&#xff09;\u4e0e\u6d88\u8d39\u8005&#xff08;\u4e3b\u5faa\u73af&#xff09;\u89e3\u8026&#xff0c;\u53cc\u7f13\u51b2\u4fdd\u8bc1&#034;\u8fb9\u6536\u8fb9\u5904\u7406&#034;&#xff0c;\u662f\u5927\u6d41\u91cf\u4e32\u53e3\/SPI \u6536\u53d1\u7684\u6807\u51c6\u67b6\u6784\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U8. \u6ce2\u7279\u7387\u8bef\u5dee\u8ba1\u7b97\u9898&#xff1a;APB1&#061;36MHz \u8dd1 115200&#xff0c;\u8bef\u5dee\u591a\u5927&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">USARTDIV &#061; 36e6\/(16\u00d7115200) &#061; 19.53125 \u2192 \u53d6\u6574\u6570 19 &#043; \u5c0f\u6570 0.53125\u00d716 \u2248 8\/16 \u2192 \u5b9e\u9645 &#061; 36e6\/(16\u00d719.5) &#061; 115384.6\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8bef\u5dee &#061; |115200 \u2212 115384.6|\/115200 \u2248 0.16% &lt; 2%&#xff0c;\u53ef\u7528\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4e3a\u4ec0\u4e48 36MHz \u7684 APB1 \u8dd1 115200 \u4e5f\u80fd\u8fc7&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u91c7\u6837\u5bb9\u5dee 3\/16 \u4f4d \u2248 1.875%&#xff0c;0.16% \u8fdc\u4f4e\u4e8e\u9608\u503c&#xff1b;\u4f46\u5982\u679c\u7528 HSI 8MHz \u4e14\u7cbe\u5ea6 \u00b11%&#xff0c;\u7d2f\u79ef\u8bef\u5dee\u5c31\u5371\u9669\u4e86\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U9. \u53d1\u9001\u4e2d\u65ad\u5b8c\u6574\u6d41\u7a0b&#xff08;TXE \u4e2d\u65ad &#043; TC \u6536\u5c3e&#xff09;<\/span><\/p>\n<p>void UART_Send_Start(uint8_t *data, uint16_t len) {   \/\/ \u4e3b\u5faa\u73af\u8c03\u7528<br \/>\n    tx_idx &#061; 0; tx_len &#061; len; tx_buf &#061; data;<br \/>\n    USART_ITConfig(USART1, USART_IT_TXE, ENABLE);      \/\/ \u5f00 TXE \u4e2d\u65ad<br \/>\n}<br \/>\nvoid USART1_IRQHandler(void) {<br \/>\n    if (USART_GetITStatus(USART1, USART_IT_TXE)) {<br \/>\n        if (tx_idx &lt; tx_len) { USART1-&gt;DR &#061; tx_buf[tx_idx&#043;&#043;]; }<br \/>\n        else { USART_ITConfig(USART1, USART_IT_TXE, DISABLE);<br \/>\n               USART_ITConfig(USART1, USART_IT_TC,  ENABLE); }  \/\/ \u8f6c\u7b49 TC<br \/>\n    }<br \/>\n    if (USART_GetITStatus(USART1, USART_IT_TC)) {       \/\/ \u5168\u90e8\u53d1\u5b8c<br \/>\n        USART_ITConfig(USART1, USART_IT_TC, DISABLE);<br \/>\n        tx_done &#061; 1;                                     \/\/ \u901a\u77e5\u4e3b\u5faa\u73af<br \/>\n    }<br \/>\n}<\/p>\n<ul>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4e3a\u4ec0\u4e48\u53d1\u5b8c\u8981&#034;TXE \u8f6c TC&#034;\u4e24\u6b65&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 TXE \u53ea\u4fdd\u8bc1 DR \u7a7a&#xff0c;TC \u624d\u4fdd\u8bc1\u79fb\u4f4d\u5bc4\u5b58\u5668\u53d1\u5b8c&#xff1b;\u4e24\u9636\u6bb5\u662f\u4e32\u53e3\u53d1\u9001\u7684\u6807\u51c6\u6536\u5c3e&#xff08;\u5bf9\u5e94 S7&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U10. \u73af\u5f62\u7f13\u51b2\u5b8c\u6574\u5b9e\u73b0&#xff08;\u624b\u6495\u9898&#xff09;<\/span><\/p>\n<p>#define RB_SIZE 256            \/\/ \u5fc5\u987b\u662f 2 \u7684\u5e42&#xff0c;\u624d\u80fd\u7528 &amp; \u53d6\u6a21<br \/>\ntypedef struct {<br \/>\n    uint8_t buf[RB_SIZE];<br \/>\n    volatile uint16_t head;    \/\/ \u5199\u7d22\u5f15&#xff1a;\u4e2d\u65ad\u91cc\u53ea\u6539\u5b83<br \/>\n    volatile uint16_t tail;    \/\/ \u8bfb\u7d22\u5f15&#xff1a;\u4e3b\u5faa\u73af\u53ea\u6539\u5b83<br \/>\n} ring_t;<\/p>\n<p>\/\/ \u4e2d\u65ad\u5199<br \/>\nvoid rb_put(ring_t *r, uint8_t d) {<br \/>\n    uint16_t next &#061; (r-&gt;head &#043; 1) &amp; (RB_SIZE &#8211; 1);<br \/>\n    if (next !&#061; r-&gt;tail) { r-&gt;buf[r-&gt;head] &#061; d; r-&gt;head &#061; next; }  \/\/ \u6ee1\u5219\u4e22<br \/>\n}<br \/>\n\/\/ \u4e3b\u5faa\u73af\u8bfb<br \/>\nint rb_get(ring_t *r, uint8_t *d) {<br \/>\n    if (r-&gt;head &#061;&#061; r-&gt;tail) return 0;      \/\/ \u7a7a<br \/>\n    *d &#061; r-&gt;buf[r-&gt;tail];<br \/>\n    r-&gt;tail &#061; (r-&gt;tail &#043; 1) &amp; (RB_SIZE &#8211; 1);<br \/>\n    return 1;<br \/>\n}<\/p>\n<ul>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4e3a\u4ec0\u4e48&#034;\u6ee1&#034;\u7528 next &#061;&#061; tail \u5224\u65ad&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u6d6a\u8d39\u4e00\u683c\u6cd5&#xff0c;\u907f\u514d head&#061;&#061;tail \u540c\u65f6\u8868\u793a&#034;\u7a7a&#034;\u548c&#034;\u6ee1&#034;\u7684\u6b67\u4e49&#xff1b;\u4ee3\u4ef7\u662f\u6700\u591a\u5b58 255 \u5b57\u8282\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">U11. \u591a\u6587\u4ef6\u5de5\u7a0b&#xff1a;uart.c\/h \u91cc extern \/ static \/ \u5934\u6587\u4ef6\u5b88\u536b\u600e\u4e48\u7528&#xff1f;<\/span><\/p>\n<p>\/* uart.h *\/<br \/>\n#ifndef __UART_H             \/\/ \u5934\u6587\u4ef6\u5b88\u536b&#xff1a;\u9632\u6b62\u91cd\u590d\u5305\u542b<br \/>\n#define __UART_H<br \/>\nvoid    UART1_Init(void);<br \/>\nint     fputc(int ch, FILE *f);<br \/>\nextern  UART_HandleTypeDef huart1;   \/\/ \u8de8\u6587\u4ef6\u5171\u4eab\u53e5\u67c4&#xff08;\u5b9a\u4e49\u5728 uart.c&#xff09;<br \/>\n#endif<\/p>\n<p>\/* uart.c *\/<br \/>\n#include &#034;uart.h&#034;<br \/>\nstatic uint8_t tx_buf[64];           \/\/ static&#xff1a;\u4ec5\u672c\u6587\u4ef6\u53ef\u89c1<br \/>\nUART_HandleTypeDef huart1;           \/\/ \u5168\u5c40\u5b9a\u4e49<\/p>\n<ul>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u5934\u6587\u4ef6\u5b88\u536b\u4e3a\u4ec0\u4e48\u5fc5\u987b&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u4e24\u4e2a .c \u90fd include \u540c\u4e00\u4e2a\u5934\u65f6&#xff0c;\u6ca1\u6709\u5b88\u536b\u4f1a\u91cd\u590d\u5b9a\u4e49\u62a5\u9519&#xff1b;\u5b88\u536b&#xff08;\u6216 #pragma once&#xff09;\u8ba9\u7b2c\u4e8c\u6b21\u5305\u542b\u53d8\u7a7a\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;extern \u548c static \u65b9\u5411\u76f8\u53cd&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 extern \u58f0\u660e&#034;\u5b83\u5b9a\u4e49\u5728\u522b\u5904&#xff0c;\u8fd9\u91cc\u53ef\u7528&#034;&#xff1b;static \u9650\u5236&#034;\u53ea\u5728\u5f53\u524d\u6587\u4ef6\u53ef\u89c1&#034;&#xff0c;\u6b63\u597d\u4e00\u5bf9\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<h3><span style=\"color:#1a439c\">\u6df1\u6316\u4e09 \u00b7 I2C \u4ee3\u7801\u7ea7&#xff08;I13\u2013I19&#xff09;<\/span><\/h3>\n<p><span style=\"color:#b95514\">I13. \u6a21\u62df I2C \u5b8c\u6574\u624b\u6495\u4ee3\u7801&#xff08;Start\/Stop\/\u6536\u53d1\/ACK &#043; EEPROM \u8bfb\u5199&#xff09;<\/span><\/p>\n<p>#define SCL_H() GPIOB-&gt;BSRR &#061; GPIO_Pin_6<br \/>\n#define SCL_L() GPIOB-&gt;BRR  &#061; GPIO_Pin_6<br \/>\n#define SDA_H() GPIOB-&gt;BSRR &#061; GPIO_Pin_7<br \/>\n#define SDA_L() GPIOB-&gt;BRR  &#061; GPIO_Pin_7<br \/>\n#define SDA_READ() ((GPIOB-&gt;IDR &amp; GPIO_Pin_7) ? 1 : 0)<\/p>\n<p>void I2C_Start(void)  { SDA_H(); SCL_H(); delay(); SDA_L(); delay(); SCL_L(); delay(); }<br \/>\nvoid I2C_Stop(void)   { SDA_L(); SCL_H(); delay(); SDA_H(); delay(); }<\/p>\n<p>void I2C_SendByte(uint8_t b) {<br \/>\n    for (int i &#061; 7; i &gt;&#061; 0; i&#8211;) {<br \/>\n        if (b &amp; (1 &lt;&lt; i)) SDA_H(); else SDA_L();<br \/>\n        SCL_H(); delay(); SCL_L(); delay();   \/\/ SCL \u9ad8\u65f6 SDA \u5fc5\u987b\u7a33\u5b9a<br \/>\n    }<br \/>\n}<br \/>\nuint8_t I2C_ReadByte(void) {<br \/>\n    uint8_t d &#061; 0; SDA_H();                   \/\/ \u91ca\u653e SDA&#xff0c;\u8ba9\u4ece\u673a\u9a71\u52a8<br \/>\n    for (int i &#061; 7; i &gt;&#061; 0; i&#8211;) {<br \/>\n        SCL_H(); delay();<br \/>\n        if (SDA_READ()) d |&#061; (1 &lt;&lt; i);<br \/>\n        SCL_L(); delay();<br \/>\n    }<br \/>\n    return d;<br \/>\n}<br \/>\nuint8_t I2C_CheckACK(void) { SDA_H(); SCL_H(); delay(); uint8_t a &#061; !SDA_READ(); SCL_L(); return a; }<br \/>\nvoid    I2C_SendACK(uint8_t ack) { if (ack) SDA_L(); else SDA_H(); SCL_H(); delay(); SCL_L(); SDA_H(); }<\/p>\n<p>uint8_t EEPROM_WriteByte(uint16_t addr, uint8_t data) {<br \/>\n    I2C_Start();<br \/>\n    I2C_SendByte(0xA0); if (!I2C_CheckACK()) return 0;   \/\/ \u5730\u5740&#043;W<br \/>\n    I2C_SendByte(addr &gt;&gt; 8);   if (!I2C_CheckACK()) return 0;<br \/>\n    I2C_SendByte(addr &amp; 0xFF); if (!I2C_CheckACK()) return 0;<br \/>\n    I2C_SendByte(data);        if (!I2C_CheckACK()) return 0;<br \/>\n    I2C_Stop();<br \/>\n    return 1;<br \/>\n}<br \/>\nuint8_t EEPROM_ReadByte(uint16_t addr) {<br \/>\n    uint8_t d;<br \/>\n    I2C_Start();<br \/>\n    I2C_SendByte(0xA0); I2C_CheckACK();<br \/>\n    I2C_SendByte(addr &gt;&gt; 8);   I2C_CheckACK();<br \/>\n    I2C_SendByte(addr &amp; 0xFF); I2C_CheckACK();<br \/>\n    I2C_Start();                                   \/\/ \u91cd\u590d\u8d77\u59cb<br \/>\n    I2C_SendByte(0xA1); I2C_CheckACK();            \/\/ \u5730\u5740&#043;R<br \/>\n    d &#061; I2C_ReadByte();<br \/>\n    I2C_SendACK(0);                                \/\/ \u6700\u540e\u4e00\u5b57\u8282 NACK<br \/>\n    I2C_Stop();<br \/>\n    return d;<br \/>\n}<\/p>\n<ul>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u6bcf\u4e2a delay \u4e3a\u4ec0\u4e48\u5fc5\u987b&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u6a21\u62df I2C \u9760\u8f6f\u4ef6\u5ef6\u65f6\u6ee1\u8db3\u65f6\u5e8f\u53c2\u6570&#xff08;\u4e0a\u5347\/\u4e0b\u964d\/\u4fdd\u6301\u65f6\u95f4&#xff09;&#xff0c;\u9ad8\u901f\u573a\u666f\u9700\u6309 tSU;STA\/tHD;DAT \u67e5\u624b\u518c\u8c03\u5ef6\u65f6\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u8fd9\u5957\u4ee3\u7801\u600e\u4e48\u6302\u591a\u4e2a\u5668\u4ef6&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u6362\u4ece\u673a\u5730\u5740\u5373\u53ef&#xff08;\u5982 0xA0\/0xA2\/0xA4\u2026\u7531 A0~A2 \u5f15\u811a\u51b3\u5b9a&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I14. HAL_I2C_Mem_Read \u5185\u90e8\u5927\u81f4\u600e\u4e48\u8d70&#xff1f;&#xff08;\u6e90\u7801\u7ea7&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">HAL_I2C_Mem_Read \u2192 I2C_RequestMemoryRead&#xff1a;\u53d1\u8d77\u59cb&#043;\u5730\u5740&#043;W&#xff08;\u7b49 TXIS&#xff09;\u2192 \u53d1\u5bc4\u5b58\u5668\u5730\u5740\u9ad8\/\u4f4e\u5b57\u8282&#xff08;\u7b49 TXIS&#xff0c;\u6bcf\u5b57\u8282\u7b49 ACK&#xff09;\u2192 \u91cd\u590d\u8d77\u59cb \u2192 \u53d1\u5730\u5740&#043;R \u2192 \u6536\u6570\u636e&#xff1a;\u524d N\u22121 \u5b57\u8282\u7b49 RXNE \u8bfb &#043; \u56de ACK&#xff0c;\u6700\u540e\u5b57\u8282\u56de NACK \u2192 \u505c\u6b62 \u2192 \u7f6e\u5b8c\u6210\u6807\u5fd7\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u5168\u7a0b\u5e26 HAL_GetTick \u8d85\u65f6&#xff0c;\u8d85\u65f6\u8fd4\u56de HAL_TIMEOUT \u5e76\u8fdb ErrorCallback\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;HAL \u963b\u585e\u6a21\u5f0f\u4e3a\u4ec0\u4e48\u8fd8\u8981\u4e2d\u65ad&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 HAL \u5185\u90e8\u7528&#034;\u4e2d\u65ad\u670d\u52a1 &#043; \u72b6\u6001\u673a\u63a8\u8fdb &#043; \u5916\u5c42\u5fd9\u7b49&#034;&#xff0c;\u672c\u8d28\u662f\u4e2d\u65ad\u9a71\u52a8\u7684\u963b\u585e\u8c03\u7528\u2014\u2014\u8fd9\u89e3\u91ca\u4e86\u4e3a\u4ec0\u4e48\u963b\u585e\u6a21\u5f0f\u91cc ISR \u4e0d\u80fd\u88ab\u6253\u65ad\u592a\u4e45\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I15. \u603b\u7ebf\u5361\u6b7b\u6062\u590d&#xff1a;9 \u4e2a\u65f6\u949f\u8109\u51b2\u600e\u4e48\u5199&#xff1f;<\/span><\/p>\n<p>void I2C_Bus_Recover(void) {<br \/>\n    for (int i &#061; 0; i &lt; 9; i&#043;&#043;) {          \/\/ \u6700\u591a 9 \u4e2a\u65f6\u949f<br \/>\n        SCL_H(); delay(); SCL_L(); delay();<br \/>\n    }<br \/>\n    I2C_Stop();                            \/\/ \u8865\u4e00\u4e2a\u505c\u6b62\u6761\u4ef6<br \/>\n}<\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u539f\u7406&#xff1a;\u5361\u6b7b\u901a\u5e38\u662f\u4ece\u673a\u628a SDA \u62c9\u6b7b\u4e0d\u91ca\u653e&#xff0c;\u4e3b\u673a\u7528\u65f6\u949f\u8109\u51b2\u5f3a\u5236\u63a8\u8fdb\u4ece\u673a\u5185\u90e8\u72b6\u6001&#xff0c;\u76f4\u5230\u4ece\u673a\u5728\u7b2c 9 \u4f4d\u91ca\u653e SDA\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;9 \u4e3a\u4ec0\u4e48\u591f&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u4ece\u673a\u4e00\u4e2a\u5b57\u8282\/\u72b6\u6001\u6700\u591a 9 \u4e2a\u65f6\u949f&#xff08;8 \u6570\u636e&#043;1 ACK&#xff09;&#xff0c;\u8109\u51b2\u4e00\u8f6e\u540e\u5fc5\u7136\u5230\u505c\u6b62\u6761\u4ef6\u9644\u8fd1\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I16. \u591a\u4e3b\u673a\u540c\u65f6\u53d1\u6570\u636e&#xff0c;\u8c01\u8d62&#xff1f;&#xff08;\u4ef2\u88c1\u9898&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u53cc\u65b9\u90fd\u53d1 1 \u65f6\u603b\u7ebf 1 \u6ca1\u95ee\u9898&#xff1b;\u67d0\u4e2a\u4e3b\u673a\u53d1 1\u3001\u53e6\u4e00\u4e2a\u53d1 0 \u2192 \u53d1 0 \u7684\u8d62&#xff08;\u5f00\u6f0f\u7ebf\u4e0e&#xff0c;\u53d1 1 \u7684\u4e3b\u673a\u68c0\u6d4b\u5230\u603b\u7ebf\u88ab\u62c9\u4f4e \u2192 \u4e22\u4ef2\u88c1&#xff0c;\u9000\u51fa&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4ef2\u88c1\u53d1\u751f\u5728\u54ea\u4e2a\u9636\u6bb5&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u5730\u5740\u4f4d\u548c\u6570\u636e\u4f4d\u90fd\u53ef\u80fd\u4ef2\u88c1&#xff1b;\u4e22\u4ef2\u88c1\u7684\u4e3b\u673a\u505c\u6b62\u53d1\u9001&#xff0c;\u603b\u7ebf\u88ab\u80dc\u8005\u63a5\u7ba1&#xff0c;\u4e0d\u4f1a\u635f\u574f\u6570\u636e\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I17. I2C \u4e2d\u65ad\u6a21\u5f0f\u8bfb EEPROM \u72b6\u6001\u673a\u600e\u4e48\u8bbe\u8ba1&#xff1f;&#xff08;10.2 \u6df1\u5ea6&#xff09;<\/span><\/p>\n<p>typedef enum { ST_START, ST_SEND_ADDR_W, ST_WAIT_ACK1, ST_SEND_REG,<br \/>\n               ST_REPEAT_START, ST_SEND_ADDR_R, ST_WAIT_ACK2,<br \/>\n               ST_READ, ST_SEND_NACK, ST_STOP } i2c_state_t;<\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u6bcf\u6536\u5230\u4e00\u4e2a\u4e8b\u4ef6\u4e2d\u65ad\u5c31\u63a8\u8fdb\u4e00\u683c&#xff1a;\u53d1\u5730\u5740\u5b8c\u6210 \u2192 \u7b49 ACK \u2192 \u53d1\u5bc4\u5b58\u5668 \u2192 \u91cd\u590d\u8d77\u59cb \u2192 \u5207 R \u2192 \u6536\u5b57\u8282&#xff08;\u8ba1\u6570&#xff09;\u2192 NACK \u2192 \u505c\u6b62\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4e3a\u4ec0\u4e48\u4e2d\u65ad\u6a21\u5f0f\u8981\u72b6\u6001\u673a\u800c\u963b\u585e\u4e0d\u7528&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u963b\u585e\u662f&#034;\u4e00\u6b21\u8c03\u7528\u91cc\u6309\u987a\u5e8f\u7b49\u5b8c\u6240\u6709\u4e8b\u4ef6&#034;&#xff1b;\u4e2d\u65ad\u6a21\u5f0f\u4e00\u4e2a\u4e8b\u4ef6\u4e00\u6b21 ISR&#xff0c;\u8c03\u7528\u65e9\u8fd4\u56de\u4e86&#xff0c;\u5fc5\u987b\u7528\u72b6\u6001\u8bb0\u5f55&#034;\u8d70\u5230\u54ea\u4e86&#034;&#xff0c;\u5426\u5219\u4e0d\u77e5\u9053\u4e0b\u4e00\u6b65\u53d1\u4ec0\u4e48\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I18. \u4e0a\u62c9\u7535\u963b &#043; \u603b\u7ebf\u7535\u5bb9\u600e\u4e48\u4f30\u7b97&#xff1f;&#xff08;\u8fdb\u9636\u786c\u4ef6\u9898&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u4e0a\u5347\u65f6\u95f4 \u2248 0.8473 \u00d7 R \u00d7 C&#xff1b;\u5feb\u901f\u6a21\u5f0f\u8981\u6c42\u4e0a\u5347 &lt;300ns&#xff08;400kHz&#xff09;&#xff0c;3.3V \u5e38\u7528 2.2k~4.7k\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u5668\u4ef6\u591a\u4e86\u7535\u963b\u8981\u6362\u5c0f&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u603b\u7ebf\u7535\u5bb9\u53d8\u5927&#xff0c;\u4e3a\u4fdd\u6301\u4e0a\u5347\u6cbf\u591f\u5feb\u8981\u51cf\u5c0f R&#xff0c;\u4f46\u529f\u8017\u4e0a\u5347\u2014\u2014\u8fd9\u5c31\u662f&#034;\u6302 8 \u4e2a\u4ece\u673a\u5bb9\u6613\u4e0d\u7a33\u5b9a&#034;\u7684\u539f\u56e0\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">I19. \u4e3a\u4ec0\u4e48 ISR \u91cc\u4e0d\u505a I2C \u6570\u636e\u5904\u7406&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">I2C \u4e2d\u65ad&#xff08;\u5c24\u5176\u8bfb\u591a\u5b57\u8282&#xff09;\u4f1a\u8fde\u7eed\u5bc6\u96c6\u89e6\u53d1&#xff0c;\u5728 ISR \u91cc\u89e3\u6790\u4e1a\u52a1\u903b\u8f91\u4f1a\u62d6\u4f4f\u5176\u4ed6\u4e2d\u65ad&#xff1b;\u6b63\u786e\u505a\u6cd5&#xff1a;ISR\/\u56de\u8c03\u53ea\u642c\u8fdb\u7f13\u51b2 &#043; \u7f6e\u6807\u5fd7&#xff0c;\u89e3\u6790\u548c\u4e1a\u52a1\u653e\u4e3b\u5faa\u73af\/\u4efb\u52a1\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<h3><span style=\"color:#1a439c\">\u6df1\u6316\u56db \u00b7 SPI \u4ee3\u7801\u7ea7&#xff08;P13\u2013P18&#xff09;<\/span><\/h3>\n<p><span style=\"color:#b95514\">P13. Flash \u8de8\u9875\u5199\u5b8c\u6574\u5b9e\u73b0&#xff08;\u624b\u6495\u9898&#xff09;<\/span><\/p>\n<p>#define PAGE_SIZE 256<br \/>\nvoid Flash_WriteBytes(uint32_t addr, uint8_t *data, uint32_t len) {<br \/>\n    while (len) {<br \/>\n        Flash_WriteEnable();                       \/\/ 0x06 \u7f6e WEL<br \/>\n        uint32_t page_left &#061; PAGE_SIZE &#8211; (addr % PAGE_SIZE);  \/\/ \u672c\u9875\u5269\u4f59<br \/>\n        uint32_t chunk &#061; (len &lt; page_left) ? len : page_left; \/\/ \u6700\u591a\u5199\u5230\u9875\u5c3e<br \/>\n        \/\/ \u53d1 0x02 &#043; 24 \u4f4d\u5730\u5740 &#043; chunk \u5b57\u8282<br \/>\n        SPI_CS_LOW();<br \/>\n        SPI_SendByte(0x02);<br \/>\n        SPI_SendByte((addr &gt;&gt; 16) &amp; 0xFF);<br \/>\n        SPI_SendByte((addr &gt;&gt; 8)  &amp; 0xFF);<br \/>\n        SPI_SendByte(addr &amp; 0xFF);<br \/>\n        for (uint32_t i &#061; 0; i &lt; chunk; i&#043;&#043;) SPI_SendByte(data[i]);<br \/>\n        SPI_CS_HIGH();<br \/>\n        Flash_WaitBusy();                          \/\/ \u8f6e\u8be2 WIP&#xff08;0x05&#xff09;<br \/>\n        addr &#043;&#061; chunk; data &#043;&#061; chunk; len -&#061; chunk;<br \/>\n    }<br \/>\n}<\/p>\n<ul>\n<li><span style=\"color:#be191c\">\u8ffd\u95ee 1&#xff1a;\u4e3a\u4ec0\u4e48\u5fc5\u987b\u7b97 page_left&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u9875\u7f16\u7a0b\u8de8\u9875\u4f1a\u5730\u5740\u56de\u7ed5\u5230\u9875\u9996&#xff0c;\u8986\u76d6\u65e7\u6570\u636e\u2014\u2014\u8fd9\u662f Flash \u9762\u8bd5\u7b2c\u4e00\u5751\u3002<\/span><\/li>\n<li><span style=\"color:#be191c\">\u8ffd\u95ee 2&#xff1a;\u6bcf\u6b21\u5199\u524d\u4e3a\u4ec0\u4e48\u90fd\u8981 WriteEnable&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 WEL \u4f4d\u5728\u4e00\u6b21\u7f16\u7a0b\/\u64e6\u9664\u5b8c\u6210\u540e\u81ea\u52a8\u6e05 0&#xff0c;\u4e0b\u6b21\u5fc5\u987b\u5148\u7f6e\u4f4d\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P14. Flash \u8bfb ID \u7684\u5b8c\u6574\u65f6\u5e8f&#xff08;\u624b\u6495&#xff09;<\/span><\/p>\n<p>SPI_CS_LOW();<br \/>\nSPI_SendByte(0x9F);                 \/\/ JEDEC ID \u547d\u4ee4<br \/>\nid[0] &#061; SPI_SendByte(0xFF);         \/\/ 3 \u4e2a\u54d1\u5b57\u8282\u63a8\u65f6\u949f&#xff0c;\u8bfb\u56de 3 \u5b57\u8282<br \/>\nid[1] &#061; SPI_SendByte(0xFF);<br \/>\nid[2] &#061; SPI_SendByte(0xFF);<br \/>\nSPI_CS_HIGH();                      \/\/ \u8bfb ID \u65f6 CS \u5168\u7a0b\u4f4e<\/p>\n<ul>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4e3a\u4ec0\u4e48\u8bfb\u8981\u53d1 0xFF&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 SPI \u5168\u53cc\u5de5&#xff1a;\u8bfb\u6570\u636e\u5fc5\u987b\u9760\u4e3b\u673a\u53d1\u5b57\u8282\u63d0\u4f9b\u65f6\u949f&#xff0c;0xFF \u662f\u901a\u7528\u54d1\u5b57\u8282&#xff08;\u5bf9\u5e94 P3&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u8bfb\u5230 ID \u5168 0xFF \u8bf4\u660e\u4ec0\u4e48&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 CS \u6ca1\u62c9\u4f4e\/\u4ece\u673a\u6ca1\u9009\u4e2d\u3001MISO \u60ac\u7a7a\u3001\u6216\u578b\u53f7\u4e0d\u652f\u6301\u8be5\u547d\u4ee4\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P15. SPI DMA \u6536\u53d1\u914d\u7f6e&#xff08;HAL \u4ee3\u7801&#xff09;&#043; \u9009\u62e9\u4f9d\u636e<\/span><\/p>\n<p>HAL_SPI_Transmit_DMA(&amp;hspi1, tx_buf, len);    \/\/ \u53d1&#xff1a;\u5185\u5b58\u2192SPI<br \/>\nHAL_SPI_Receive_DMA (&amp;hspi1, rx_buf, len);    \/\/ \u6536&#xff1a;SPI\u2192\u5185\u5b58<br \/>\nvoid HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi) { tx_done &#061; 1; }<\/p>\n<ul>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;SPI \u5168\u53cc\u5de5 &#043; DMA \u5e94\u8be5\u7528\u54ea\u4e2a\u51fd\u6570&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u6536\u53d1\u540c\u65f6\u5f00\u65f6\u7528 HAL_SPI_TransmitReceive_DMA&#xff0c;\u4e00\u6b21\u9a71\u52a8\u4e24\u6761 DMA \u901a\u9053\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4ec0\u4e48\u65f6\u5019\u7528\u4e2d\u65ad\/DMA&#xff0c;\u4ec0\u4e48\u65f6\u5019\u8f6e\u8be2&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u51e0\u5b57\u8282\u8c03\u8bd5\u8f6e\u8be2&#xff1b;\u51e0\u5341\u5b57\u8282\u4e2d\u65ad&#xff1b;\u5927\u5757\u6570\u636e&#xff08;Flash \u9875\u7f16\u7a0b\u3001\u5237\u5c4f&#xff09;\u5fc5\u987b DMA&#xff0c;\u91cf\u5316\u7406\u7531\u540c U6\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P16. \u786c\u4ef6 NSS vs \u8f6f\u4ef6 CS&#xff0c;\u4e3a\u4ec0\u4e48\u63a8\u8350\u8f6f\u4ef6 CS&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u786c\u4ef6 NSS&#xff1a;\u5916\u8bbe\u81ea\u52a8\u63a7\u5236\u7247\u9009&#xff0c;\u4f46\u65f6\u5e8f\u53d7\u5916\u8bbe\u72b6\u6001\u673a\u7ea6\u675f&#xff08;\u5982\u8d77\u59cb\/\u7ed3\u675f\u5bf9\u9f50&#xff09;&#xff0c;\u591a\u4ece\u673a\u5207\u6362\u9ebb\u70e6&#xff0c;\u6613\u8e29\u5751\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8f6f\u4ef6 CS&#xff1a;\u4efb\u610f GPIO \u624b\u52a8\u62c9\u4f4e\/\u62c9\u9ad8&#xff0c;\u65f6\u5e8f\u5b8c\u5168\u81ea\u5df1\u63a7\u5236&#xff0c;\u591a\u4ece\u673a\u968f\u4fbf\u6269\u5c55\u2014\u2014\u5de5\u7a0b\u4e0a 90% \u7528\u8f6f\u4ef6 CS\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u8f6f\u4ef6 CS \u8981\u6ce8\u610f\u4ec0\u4e48&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u5148\u62c9\u4f4e\u518d\u53d1\u9996\u5b57\u8282\u3001\u53d1\u5b8c\u7b49 BSY \u6e05\u518d\u62c9\u9ad8&#xff08;\u89c1 P4&#xff09;&#xff0c;\u8fd9\u4e24\u4e2a\u65f6\u673a\u9519\u4e00\u4e2a\u6570\u636e\u5c31\u4e22\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P17. \u4e3a\u4ec0\u4e48\u53d1\u5b8c\u8981\u7b49 BSY&#xff1f;&#xff08;\u9010\u5b57\u8282\u65f6\u5e8f&#xff09;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">TXE \u6e05 &#061; DR \u7a7a&#xff0c;\u4f46\u79fb\u4f4d\u5bc4\u5b58\u5668\u53ef\u80fd\u8fd8\u5728\u79fb\u51fa\u6700\u540e\u4e00\u4f4d&#xff1b;BSY&#061;1 \u8868\u793a\u4ecd\u5728\u79fb\u4f4d&#xff0c;\u4e0d\u7b49\u5c31\u62c9\u9ad8 CS\/\u5173 SPI \u2192 \u5c3e\u5b57\u8282\u6b8b\u7f3a\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u548c\u4e32\u53e3 TC \u662f\u4e00\u4e2a\u9053\u7406&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u5b8c\u5168\u540c\u6784&#xff1a;DR \u7a7a \u2260 \u53d1\u9001\u5b8c\u6210&#xff0c;\u5bc4\u5b58\u5668\u7ea7&#034;\u6700\u540e\u4e00\u5b57\u8282&#034;\u5fc5\u987b\u7b49\u786c\u4ef6\u5b8c\u6210\u4fe1\u53f7\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">P18. SPI \u6a21\u5f0f\u8ba1\u7b97\u9898&#xff1a;MODE 0 \u548c MODE 3 \u7684\u6ce2\u5f62\u533a\u522b&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u90fd\u662f\u7b2c\u4e00\u4e2a\u65f6\u949f\u6cbf\u91c7\u6837&#xff08;CPHA&#061;0\/1 \u76f8\u4f4d\u4e00\u81f4&#xff09;&#xff0c;\u533a\u522b\u53ea\u5728\u7a7a\u95f2\u7535\u5e73&#xff1a;MODE0 \u7a7a\u95f2\u4f4e\u3001MODE3 \u7a7a\u95f2\u9ad8\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4e3a\u4ec0\u4e48 Flash \u4e24\u4e2a\u90fd\u517c\u5bb9&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u5927\u591a\u6570 Flash \u5bf9\u7a7a\u95f2\u7535\u5e73\u4e0d\u654f\u611f&#xff08;\u53ea\u5728\u91c7\u6837\u70b9\u8bfb\u6570\u636e&#xff09;&#xff0c;\u4e3b\u673a\u6309\u624b\u518c\u914d MODE0 \u6216 MODE3 \u90fd\u80fd\u901a\u4fe1\u2014\u2014\u4f46\u91c7\u6837\u70b9\u9519\u4e86&#xff08;MODE1\/2&#xff09;\u4e00\u5b9a\u4e71\u7801\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<h3><span style=\"color:#1a439c\">\u6df1\u6316\u4e94 \u00b7 \u65f6\u949f\u6811\u8ba1\u7b97\u9898&#xff08;C1\u2013C4&#xff09;<\/span><\/h3>\n<p><span style=\"color:#b95514\">C1. \u7efc\u5408\u8ba1\u7b97&#xff1a;72MHz \u7cfb\u7edf\u4e0b&#xff0c;\u914d 115200 \u4e32\u53e3&#xff08;USART2&#xff09;\u30011ms \u5b9a\u65f6\u5668&#xff08;TIM3&#xff09;\u300110MHz SPI&#xff08;SPI1&#xff09;&#xff0c;\u5404\u81ea\u5206\u9891\u586b\u591a\u5c11&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">USART2 \u5728 APB1&#061;36MHz&#xff1a;USARTDIV &#061; 36e6\/(16\u00d7115200) \u2248 19.53 \u2192 BRR\u22480x13B&#xff08;\u8bef\u5dee 0.16%&#xff0c;\u89c1 U8&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">TIM3 \u5728 APB1&#xff0c;\u9884\u5206\u9891\u22601 \u2192 \u5b9a\u65f6\u5668\u65f6\u949f 72MHz&#xff1a;(PSC&#043;1)\u00d7(ARR&#043;1) &#061; 72e6\/1000 &#061; 72000 \u2192 PSC&#061;71, ARR&#061;999&#xff08;\u89c1 R5&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">SPI1 \u5728 APB2&#061;72MHz&#xff1a;\u8981 10MHz \u2192 \u9884\u5206\u9891 8&#xff08;72\/8&#061;9MHz&#xff0c;\u6700\u63a5\u8fd1\u4e14\u4e0d\u8d85&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8003\u70b9&#xff1a;\u4e09\u6761\u7ebf\u5206\u522b\u7528\u5bf9 APB1\/APB2\/\u5b9a\u65f6\u5668\u00d72 \u89c4\u5219\u2014\u2014\u9519\u4e00\u6761\u7b54\u6848\u5c31\u9519\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">C2. ADC \u91c7\u6837\u7387\u4e0a\u9650\u600e\u4e48\u7b97&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">F1 ADC \u65f6\u949f\u4e0a\u9650 14MHz&#xff08;APB2 \u518d\u5206\u9891 2\/4\/6\/8&#xff09;&#xff1b;\u6700\u77ed\u8f6c\u6362 &#061; 1.5&#xff08;\u6700\u77ed\u91c7\u6837&#xff09;&#043; 12.5&#xff08;\u56fa\u5b9a\u8f6c\u6362&#xff09;&#061; 14 \u5468\u671f\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u4e0a\u9650 \u2248 14MHz\/14 &#061; 1MSPS&#xff1b;\u5b9e\u9645\u8fd8\u8981\u7559\u88d5\u91cf&#xff0c;\u5e38\u7528 500k~900k\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u63d0\u9ad8\u91c7\u6837\u7387\u7684\u4e24\u4e2a\u6760\u6746&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 \u63d0\u9ad8 ADC \u65f6\u949f&#xff08;\u226414M&#xff09;\u3001\u7f29\u77ed\u91c7\u6837\u5468\u671f&#xff08;\u22641.5&#xff09;&#xff0c;\u4f46\u91c7\u6837\u5468\u671f\u592a\u77ed\u7cbe\u5ea6\u4e0b\u964d\u2014\u2014\u9ad8\u901f\u9ad8\u7cbe\u5ea6\u4e0d\u53ef\u517c\u5f97\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">C3. Flash \u7b49\u5f85\u5468\u671f&#xff08;WS&#xff09;\u548c\u4e3b\u9891\u4ec0\u4e48\u5173\u7cfb&#xff1f;\u4e3a\u4ec0\u4e48\u8d85\u9891\u8981\u6539\u5b83&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">F1 \u89c4\u5219&#xff1a;\u4e3b\u9891 \u226424MHz \u2192 0WS&#xff1b;\u226448MHz \u2192 1WS&#xff1b;\u226472MHz \u2192 2WS\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u914d\u9519&#xff1a;\u4e3b\u9891\u9ad8 &#043; WS \u5c0f \u2192 CPU \u4ece Flash \u53d6\u6307\u8bfb\u5230\u65e7\/\u9519\u6570\u636e \u2192 \u968f\u673a HardFault\u3002<\/span><\/li>\n<li><span style=\"color:#fe2c24\">\u8ffd\u95ee&#xff1a;\u4e3a\u4ec0\u4e48 72MHz \u5fc5\u987b 2WS&#xff1f;<\/span><span style=\"color:#0d0016\">\u2192 Flash \u8bbf\u95ee\u901f\u5ea6\u6709\u7269\u7406\u4e0a\u9650&#xff08;\u7ea6 24MHz\/WS&#xff09;&#xff0c;CPU \u66f4\u5feb\u5c31\u5fc5\u987b\u63d2\u7b49\u5f85\u5468\u671f&#xff0c;\u5426\u5219\u53d6\u6307\u9519\u4e71\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<p><span style=\"color:#b95514\">C4. \u573a\u666f\u9898&#xff1a;\u6362\u4e86\u4e2a 12MHz \u6676\u632f&#xff0c;\u7a0b\u5e8f\u8fd8\u6309 8MHz \u00d79 \u914d&#xff0c;\u4f1a\u600e\u6837&#xff1f;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u5b9e\u9645 SYSCLK &#061; 12\u00d79 &#061; 108MHz \u2192 \u8d85\u51fa 72MHz \u4e0a\u9650&#xff1a;Flash WS \u4e0d\u591f\u3001\u5916\u8bbe\u8d85\u9891&#xff08;APB1&#061;54MHz&gt;36MHz&#xff09;\u2192 \u4e71\u7801\/\u968f\u673a HardFault\/\u5916\u8bbe\u5f02\u5e38\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u6b63\u786e\u505a\u6cd5&#xff1a;PLL \u500d\u9891\u6539\u6210 6&#xff08;12\u00d76&#061;72&#xff09;\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u8ffd\u95ee&#xff1a;\u8fd9\u4e5f\u662f\u4ea7\u54c1\u5316\u5e38\u8003&#xff1a;\u6676\u632f\u9891\u7387\u53d8\u4e86&#xff0c;\u65f6\u949f\u914d\u7f6e\u5fc5\u987b\u8ddf\u7740\u53d8\u2014\u2014\u6240\u4ee5\u91cf\u4ea7\u7528 Bootloader \u81ea\u9002\u5e94\u6216\u5199\u6b7b\u524d\u5148\u9a8c\u8bc1\u3002<\/span><\/li>\n<\/ul>\n<hr \/>\n<h3><span style=\"color:#1a439c\">\u6df1\u6c34\u533a\u9ad8\u9891\u901f\u67e5<\/span><\/h3>\n<table>\n<tr><span style=\"color:#0d0016\">\u9898<\/span><span style=\"color:#0d0016\">\u4e00\u53e5\u8bdd\u7b54\u6848<\/span><\/tr>\n<tbody>\n<tr>\n<td><span style=\"color:#0d0016\">\u538b\u6808\u51e0\u4e2a\u5bc4\u5b58\u5668<\/span><\/td>\n<td><span style=\"color:#0d0016\">8 \u4e2a&#xff1a;xPSR\/PC\/LR\/R12\/R3~R0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">EXC_RETURN 0xFFFFFFFD<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u7ebf\u7a0b\u6a21\u5f0f&#043;PSP &#061; RTOS \u4efb\u52a1\u6808<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">R4~R11 \u8c01\u538b<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u8f6f\u4ef6&#xff08;PendSV\/\u7f16\u8bd1\u5668&#xff09;<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">IDLE \u957f\u5ea6\u600e\u4e48\u7b97<\/span><\/td>\n<td><span style=\"color:#0d0016\">BUFSZ \u2212 CNDTR<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u73af\u5f62\u7f13\u51b2&#034;\u6ee1&#034;\u5224\u65ad<\/span><\/td>\n<td><span style=\"color:#0d0016\">(head&#043;1)%size &#061;&#061; tail&#xff08;\u6d6a\u8d39\u4e00\u683c&#xff09;<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u8bfb EEPROM \u4e3a\u4ec0\u4e48\u91cd\u590d\u8d77\u59cb<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u9632\u5176\u4ed6\u4e3b\u673a\u63d2\u961f&#xff0c;\u4fdd\u6301\u539f\u5b50<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u6700\u540e\u4e00\u5b57\u8282\u4e3a\u4ec0\u4e48 NACK<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u544a\u77e5\u4ece\u673a\u505c\u6b62&#xff0c;\u624d\u80fd\u6b63\u5e38\u53d1\u505c\u6b62\u4f4d<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">Flash \u4e3a\u4ec0\u4e48\u5148\u64e6\u540e\u5199<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u7f16\u7a0b\u53ea\u80fd 1\u21920&#xff0c;\u64e6\u9664\u6062\u590d\u5168 1<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u8de8\u9875\u5199\u4e3a\u4ec0\u4e48\u62c6<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u9875\u5730\u5740\u56de\u7ed5\u4f1a\u8986\u76d6\u65e7\u6570\u636e<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">\u53d1\u5b8c\u4e3a\u4ec0\u4e48\u7b49 BSY\/TC<\/span><\/td>\n<td><span style=\"color:#0d0016\">DR \u7a7a\u2260\u53d1\u5b8c&#xff0c;\u5c3e\u5b57\u8282\u8fd8\u5728\u79fb\u4f4d<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">72MHz \u4e0b SysTick 1ms<\/span><\/td>\n<td><span style=\"color:#0d0016\">LOAD &#061; 71999<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"color:#0d0016\">F1 ADC \u91c7\u6837\u7387\u4e0a\u9650<\/span><\/td>\n<td><span style=\"color:#0d0016\">\u22481MSPS&#xff08;14MHz\/14 \u5468\u671f&#xff09;<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1292\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261003124935-6ac0f9dfd941f.png\" width=\"2558\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>STM32 \u5168\u5957\u5916\u8bbe\u9762\u8bd5\u9898\u5e93\u00a0\u00a0\u6a21\u5757\u4e00 \u00b7 GPIO&#xff08;LED \u8f93\u51fa\u3001\u6309\u952e\u8f93\u5165&#xff09;G1\u2013G10G1. STM32 \u7684 8 \u79cd GPIO \u6a21\u5f0f\u5206\u522b\u662f\u4ec0\u4e48&#xff1f;\u5404\u7528\u4e8e\u4ec0\u4e48\u573a\u666f&#xff1f;&#xff08;\u5fc5\u8003&#xff09;\u6a21\u5f0f\u7279\u70b9\u5178\u578b\u7528\u9014\u8f93\u5165\u6d6e\u7a7a\u9ad8\u963b&#xff0c;\u7535\u5e73\u5b8c\u5168\u7531\u5916\u90e8\u51b3\u5b9a\u65e0\u4e0a\u4e0b\u62c9\u7684\u4fe1\u53f7\u76d1\u6d4b\u8f93\u5165\u4e0a\u62c9\u5185\u90e8\u4e0a\u62c9&#xff0c;\u9ed8\u8ba4\u8bfb\u9ad8\u6309\u952e\u6309\u4e0b\u63a5\u5730\u68c0\u6d4b\u8f93\u5165\u4e0b\u62c9\u5185\u90e8\u4e0b\u62c9&#xff0c;\u9ed8\u8ba4\u8bfb\u4f4e\u6309\u952e\u6309\u4e0b\u63a5 VCC \u68c0\u6d4b\u6a21\u62df\u8f93\u5165\u5173\u95ed\u6570\u5b57\u7f13\u51b2AD<\/p>\n","protected":false},"author":2,"featured_media":112501,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[217,270,269,190],"topic":[],"class_list":["post-112505","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-stm32","tag-270","tag-269","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010STM32\u3011 \u9636\u6bb5\u6027\u9762\u8bd5\u9898\uff08\u767e\u9898\u590d\u4e60\uff09 - \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\/112505.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010STM32\u3011 \u9636\u6bb5\u6027\u9762\u8bd5\u9898\uff08\u767e\u9898\u590d\u4e60\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"STM32 \u5168\u5957\u5916\u8bbe\u9762\u8bd5\u9898\u5e93\u00a0\u00a0\u6a21\u5757\u4e00 \u00b7 GPIO&#xff08;LED \u8f93\u51fa\u3001\u6309\u952e\u8f93\u5165&#xff09;G1\u2013G10G1. STM32 \u7684 8 \u79cd GPIO \u6a21\u5f0f\u5206\u522b\u662f\u4ec0\u4e48&#xff1f;\u5404\u7528\u4e8e\u4ec0\u4e48\u573a\u666f&#xff1f;&#xff08;\u5fc5\u8003&#xff09;\u6a21\u5f0f\u7279\u70b9\u5178\u578b\u7528\u9014\u8f93\u5165\u6d6e\u7a7a\u9ad8\u963b&#xff0c;\u7535\u5e73\u5b8c\u5168\u7531\u5916\u90e8\u51b3\u5b9a\u65e0\u4e0a\u4e0b\u62c9\u7684\u4fe1\u53f7\u76d1\u6d4b\u8f93\u5165\u4e0a\u62c9\u5185\u90e8\u4e0a\u62c9&#xff0c;\u9ed8\u8ba4\u8bfb\u9ad8\u6309\u952e\u6309\u4e0b\u63a5\u5730\u68c0\u6d4b\u8f93\u5165\u4e0b\u62c9\u5185\u90e8\u4e0b\u62c9&#xff0c;\u9ed8\u8ba4\u8bfb\u4f4e\u6309\u952e\u6309\u4e0b\u63a5 VCC \u68c0\u6d4b\u6a21\u62df\u8f93\u5165\u5173\u95ed\u6570\u5b57\u7f13\u51b2AD\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/112505.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-03T12:49:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261003124930-6ac0f9da7bb3a.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=\"29 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/112505.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/112505.html\",\"name\":\"\u3010STM32\u3011 \u9636\u6bb5\u6027\u9762\u8bd5\u9898\uff08\u767e\u9898\u590d\u4e60\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-03T12:49:38+00:00\",\"dateModified\":\"2026-10-03T12:49:38+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/112505.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/112505.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/112505.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010STM32\u3011 \u9636\u6bb5\u6027\u9762\u8bd5\u9898\uff08\u767e\u9898\u590d\u4e60\uff09\"}]},{\"@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":"\u3010STM32\u3011 \u9636\u6bb5\u6027\u9762\u8bd5\u9898\uff08\u767e\u9898\u590d\u4e60\uff09 - \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\/112505.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010STM32\u3011 \u9636\u6bb5\u6027\u9762\u8bd5\u9898\uff08\u767e\u9898\u590d\u4e60\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"STM32 \u5168\u5957\u5916\u8bbe\u9762\u8bd5\u9898\u5e93\u00a0\u00a0\u6a21\u5757\u4e00 \u00b7 GPIO&#xff08;LED \u8f93\u51fa\u3001\u6309\u952e\u8f93\u5165&#xff09;G1\u2013G10G1. STM32 \u7684 8 \u79cd GPIO \u6a21\u5f0f\u5206\u522b\u662f\u4ec0\u4e48&#xff1f;\u5404\u7528\u4e8e\u4ec0\u4e48\u573a\u666f&#xff1f;&#xff08;\u5fc5\u8003&#xff09;\u6a21\u5f0f\u7279\u70b9\u5178\u578b\u7528\u9014\u8f93\u5165\u6d6e\u7a7a\u9ad8\u963b&#xff0c;\u7535\u5e73\u5b8c\u5168\u7531\u5916\u90e8\u51b3\u5b9a\u65e0\u4e0a\u4e0b\u62c9\u7684\u4fe1\u53f7\u76d1\u6d4b\u8f93\u5165\u4e0a\u62c9\u5185\u90e8\u4e0a\u62c9&#xff0c;\u9ed8\u8ba4\u8bfb\u9ad8\u6309\u952e\u6309\u4e0b\u63a5\u5730\u68c0\u6d4b\u8f93\u5165\u4e0b\u62c9\u5185\u90e8\u4e0b\u62c9&#xff0c;\u9ed8\u8ba4\u8bfb\u4f4e\u6309\u952e\u6309\u4e0b\u63a5 VCC \u68c0\u6d4b\u6a21\u62df\u8f93\u5165\u5173\u95ed\u6570\u5b57\u7f13\u51b2AD","og_url":"https:\/\/www.wsisp.com\/helps\/112505.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-03T12:49:38+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261003124930-6ac0f9da7bb3a.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"29 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/112505.html","url":"https:\/\/www.wsisp.com\/helps\/112505.html","name":"\u3010STM32\u3011 \u9636\u6bb5\u6027\u9762\u8bd5\u9898\uff08\u767e\u9898\u590d\u4e60\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-03T12:49:38+00:00","dateModified":"2026-10-03T12:49:38+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/112505.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/112505.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/112505.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010STM32\u3011 \u9636\u6bb5\u6027\u9762\u8bd5\u9898\uff08\u767e\u9898\u590d\u4e60\uff09"}]},{"@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\/112505","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=112505"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/112505\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/112501"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=112505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=112505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=112505"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=112505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}