{"id":109,"date":"2024-06-19T14:16:21","date_gmt":"2024-06-19T06:16:21","guid":{"rendered":"https:\/\/aoofoo.com\/?p=109"},"modified":"2024-06-20T19:40:47","modified_gmt":"2024-06-20T11:40:47","slug":"stm32-3","status":"publish","type":"post","link":"https:\/\/aoofoo.com\/index.php\/2024\/06\/19\/stm32-3\/","title":{"rendered":"2.3 \u65b0\u5efa\u5de5\u7a0b"},"content":{"rendered":"<h2>\u5bfc\u8bed<\/h2>\n<p>\u76ee\u524dSTM32\u7684\u5f00\u53d1\u65b9\u5f0f\u4e3b\u8981\u662f\u6709\u57fa\u4e8e\u5bc4\u5b58\u5668\u7684\u65b9\u5f0f\u3001\u57fa\u4e8e\u6807\u51c6\u5e93(\u5e93\u51fd\u6570)\u7684\u65b9\u5f0f\u3001\u57fa\u4e8eHAL\u5e93\u7684\u65b9\u5f0f\u3002<\/p>\n<p>\u57fa\u4e8e\u5bc4\u5b58\u5668\u7684\u65b9\u5f0f\uff0c\u662f\u7528\u7a0b\u5e8f\u76f4\u63a5\u914d\u7f6e\u5bc4\u5b58\u5668\uff0c\u6765\u8fbe\u5230\u6211\u4eec\u60f3\u8981\u7684\u529f\u80fd\uff0c\u8fd9\u79cd\u65b9\u5f0f\u6700\u5e95\u5c42\u3001\u6700\u76f4\u63a5\u3001\u6548\u7387\u4f1a\u66f4\u9ad8\u4e00\u4e9b\uff0c\u4f46\u662f\u7531\u4e8eSTM32\u7684\u7ed3\u6784\u590d\u6742\u3001\u5bc4\u5b58\u5668\u592a\u591a\uff0c\u6240\u4ee5\u57fa\u4e8e\u5bc4\u5b58\u5668\u7684\u65b9\u5f0f\u76ee\u524d\u662f\u4e0d\u63a8\u8350\u7684\u3002<\/p>\n<p>\u57fa\u4e8e\u5e93\u51fd\u6570\u7684\u65b9\u5f0f\u662f\u4f7f\u7528ST\u5b98\u65b9\u63d0\u4f9b\u7684\u5c01\u88c5\u597d\u7684\u51fd\u6570\uff0c\u901a\u8fc7\u8c03\u7528\u8fd9\u4e9b\u51fd\u6570\u6765\u95f4\u63a5\u5730\u914d\u7f6e\u5bc4\u5b58\u5668\uff0c\u7531\u4e8eST\u5bf9\u5bc4\u5b58\u5668\u5c01\u88c5\u7684\u6bd4\u8f83\u597d\uff0c\u6240\u4ee5\u8fd9\u79cd\u65b9\u5f0f\u65e2\u80fd\u6ee1\u8db3\u5bf9\u5bc4\u5b58\u5668\u7684\u914d\u7f6e\uff0c\u5bf9\u5f00\u53d1\u4eba\u5458\u4e5f\u6bd4\u8f83\u53cb\u597d\uff0c\u6709\u5229\u4e8e\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u3002<\/p>\n<p>\u57fa\u4e8eHAL\u5e93\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u7528\u56fe\u5f62\u5316\u754c\u9762\u5feb\u901f\u914d\u7f6eSTM32\uff0c\u8fd9\u4e2a\u6bd4\u8f83\u9002\u5408\u5feb\u901f\u4e0a\u624bSTM32\u7684\u60c5\u51b5\uff0c\u4f46\u662f\u8fd9\u79cd\u65b9\u5f0f\u9690\u85cf\u4e86\u5e95\u5c42\u903b\u8f91\uff0c\u5982\u679c\u4f60\u5bf9STM32\u4e0d\u719f\u6089\uff0c\u57fa\u672c\u53ea\u80fd\u505c\u7559\u5728\u5f88\u6d45\u7684\u6c34\u5e73\uff0c\u63a8\u8350\u5728\u5b66\u8fc7\u6807\u51c6\u5e93\u4e4b\u540e\u518d\u53bb\u4e86\u89e3\u8fd9\u4e2a\u65b9\u5f0f\uff0c\u6bd5\u7adfHAL\u5e93\u8fd8\u662f\u5f88\u65b9\u4fbf\u7684\u3002<\/p>\n<h2>\u65b0\u5efa\u5de5\u7a0b<\/h2>\n<p>\u6211\u4eec\u4f7f\u7528\u5e93\u51fd\u6570\u7684\u65b9\u5f0f\uff0c\u9700\u8981\u51c6\u5907\u4e00\u4e2a<a href=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/\u56fa\u4ef6\u5e93.zip\">STM32\u5e93\u51fd\u6570\u7684\u538b\u7f29\u5305<\/a>\u3002<\/p>\n<p>\u5728Keil5\u4e2d\u9009\u62e9Project\u65b0\u5efa\u4e00\u4e2a\u9879\u76ee\uff0c\u9009\u62e9STM32F103C8\u7684\u578b\u53f7\uff0c\u70b9\u51fbOK\u540e\u4f1a\u5f39\u51fa\u4e00\u4e2a\u65b0\u5efa\u5de5\u7a0b\u5c0f\u52a9\u624b\uff0c\u8fd9\u4e2a\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5feb\u901f\u65b0\u5efa\u5de5\u7a0b\uff0c\u4f46\u6211\u4eec\u6682\u65f6\u4e0d\u7528\u8fd9\u4e2a\u5c0f\u52a9\u624b\uff0c\u628a\u4ed6\u5173\u95ed\u3002<img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-223\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/2-2.png\" alt=\"\" width=\"365\" height=\"297\" \/><\/p>\n<p>\u73b0\u5728\u5de5\u7a0b\u5c31\u5efa\u597d\u4e86\uff0c\u4f46\u662f\u6ca1\u6709\u5de5\u7a0b\u6587\u4ef6\uff0c\u73b0\u5728\u8fd9\u4e2a\u5de5\u7a0b\u8fd8\u662f\u6ca1\u529e\u6cd5\u7528\u7684\uff0c\u9700\u8981\u7ed9\u5b83\u6dfb\u52a0\u4e00\u70b9\u5de5\u7a0b\u7684\u5fc5\u8981\u6587\u4ef6\u3002<\/p>\n<h3>Start\u6587\u4ef6\u5939\uff08\u5fc5\u8981\u6587\u4ef6\u590d\u5236\uff09<\/h3>\n<p>\u6253\u5f00\u56fa\u4ef6\u5e93\u7684\u6587\u4ef6\u5939\uff0c\u56fa\u4ef6\u5e93\\Libraries\\CMSIS\\CM3\\DeviceSupport\\ST\\STM32F10x\\startup\\arm\uff0c\u627e\u5230\u542f\u52a8\u6587\u4ef6\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-224\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/1-2.png\" alt=\"\" width=\"220\" height=\"157\" \/><\/p>\n<p>\u8fd9\u4e9b\u5c31\u662fSTN32\u7684\u542f\u52a8\u6587\u4ef6\uff0cSTM32\u7684\u7a0b\u5e8f\u5c31\u662f\u4ece\u542f\u52a8\u6587\u4ef6\u5f00\u59cb\u6267\u884c\u7684\uff0c\u628a\u8fd9\u4e9b\u6587\u4ef6\u5168\u90e8\u590d\u5236\uff0c\u6253\u5f00\u521a\u624d\u65b0\u5efa\u7684\u5de5\u7a0b\u6a21\u677f\u6587\u4ef6\u5939\uff0c\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6\u5939\uff0c\u53ef\u4ee5\u53eb\u505aStart\uff0c\u628a\u6587\u4ef6\u590d\u5236\u8fdb\u53bb\u3002<\/p>\n<p>\u518d\u6253\u5f00\u56fa\u4ef6\u5e93\u7684\u6587\u4ef6\u5939\uff0c\u56fa\u4ef6\u5e93\\Libraries\\CMSIS\\CM3\\DeviceSupport\\ST\\STM32F10x\uff0c\u53ef\u4ee5\u770b\u5230stm32f10x.h\u548c\u4e24\u4e2asystem\u5f00\u5934\u7684\u6587\u4ef6\u3002<\/p>\n<p>stm32f10x.h\u5c31\u662fSTM32\u7684\u5916\u8bbe\u5bc4\u5b58\u5668\u63cf\u8ff0\u6587\u4ef6\uff0c\u662f\u7528\u6765\u63cf\u8ff0STM32\u6709\u54ea\u4e9b\u5bc4\u5b58\u5668\u548c\u5b83\u5bf9\u5e94\u7684\u5730\u5740\u3002<\/p>\n<p>\u4e24\u4e2asystem\u6587\u4ef6\u662f\u7528\u6765\u914d\u7f6e\u65f6\u949f\u7684\uff0cSTM32\u4e3b\u989172MHz\uff0c\u5c31\u662fsystem\u6587\u4ef6\u91cc\u7684\u51fd\u6570\u914d\u7f6e\u7684\uff0c\u628a\u8fd9\u4e09\u4e2a\u6587\u4ef6\u590d\u5236\uff0c\u4e5f\u7c98\u8d34\u81f3Start\u6587\u4ef6\u5939\u4e0b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-225\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/1-3.png\" alt=\"\" width=\"273\" height=\"143\" \/><\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u56e0\u4e3a\u8fd9\u4e2aSTM32\u662f\u5185\u6838\u548c\u5185\u6838\u5916\u4e3a\u7684\u8bbe\u5907\u7ec4\u6210\u7684\uff0c\u800c\u4e14\u5185\u6838\u7684\u5bc4\u5b58\u5668\u63cf\u8ff0\u548c\u5916\u56f4\u8bbe\u5907\u7684\u63cf\u8ff0\u6587\u4ef6\u4e0d\u5728\u4e00\u8d77\uff0c\u6240\u4ee5\u6211\u4eec\u8fd8\u9700\u8981\u6dfb\u52a0\u4e00\u4e2a\u5185\u6838\u5bc4\u5b58\u5668\u7684\u63cf\u8ff0\u6587\u4ef6\u3002<\/p>\n<p>\u6253\u5f00\u56fa\u4ef6\u5e93\uff0c\u56fa\u4ef6\u5e93\\Libraries\\CMSIS\\CM3\\CoreSupport\uff0c\u8fd9\u4e24\u4e2acm3\uff08Cortex-M3\uff09\u6587\u4ef6\u5c31\u662f\u5185\u6838\u5bc4\u5b58\u5668\u7684\u63cf\u8ff0\uff0c\u5f53\u7136\u8fd8\u5e26\u4e86\u4e00\u4e9b\u5185\u6838\u7684\u914d\u7f6e\u51fd\u6570\uff0c\u6240\u4ee5\u591a\u4e86\u4e2a.c\u6587\u4ef6\uff0c\u6211\u4eec\u4e00\u5e76\u628a\u4ed6\u4fe9\u590d\u5236\u4e0b\u6765\u7c98\u8d34\u81f3Start\u6587\u4ef6\u5939\u4e0b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-226\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/1-4.png\" alt=\"\" width=\"269\" height=\"110\" \/><\/p>\n<p>\u5230\u6b64\u4e3a\u6b62\uff0c\u5de5\u7a0b\u7684\u5fc5\u8981\u6587\u4ef6\u5df2\u7ecf\u590d\u5236\u5b8c\u6210\u4e86\u3002<\/p>\n<p>\u6253\u5f00Keil\uff0c\u53ef\u4ee5\u5355\u51fb\u540d\u79f0\u5c06\u6587\u4ef6\u5939\u540d\u6539\u6210start\uff0c\u7136\u540e\u53cc\u51fb\u8fdb\u884c\u6587\u4ef6\u7684\u6dfb\u52a0\u3002<\/p>\n<div class=\"sc-collapse\"><div class=\"sc-collapse__header\"><svg class=\"sc-collapse__arrow\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"6 9 12 15 18 9\"\/><\/svg>\u542f\u52a8\u6587\u4ef6\u8be6\u60c5<\/div><div class=\"sc-collapse__body\"><div class=\"sc-collapse__content\"><\/p>\n<p>\u542f\u52a8\u6587\u4ef6\u6709\u5f88\u591a\u7c7b\u578b\uff0c\u9009\u54ea\u4e00\u4e2a\u8981\u6839\u636e\u82af\u7247\u4fe1\u53f7\u8fdb\u884c\u9009\u62e9<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-250\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/1-17.png\" alt=\"\" width=\"452\" height=\"195\" \/><\/p>\n<p><\/div><\/div><\/div>\n<p>\u542f\u52a8\u6587\u4ef6\u6709\u5f88\u591a\u7684\u5206\u7c7b\uff0c\u6211\u4eec\u53ea\u80fd\u6dfb\u52a0\u5176\u4e2d\u4e00\u4e2a\uff0c\u6211\u4eec\u6240\u7528\u7684\u578b\u53f7\u9700\u8981\u9009\u62e9\u540e\u7f00\u4e3amd.s\u7684\u542f\u52a8\u6587\u4ef6\uff0c\u81f3\u4e8e\u542f\u52a8\u6587\u4ef6\u5982\u4f55\u9009\u62e9\uff0c\u6298\u53e0\u5185\u5bb9\u4f1a\u8be6\u7ec6\u4ecb\u7ecd\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-227\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/1-5.png\" alt=\"\" width=\"325\" height=\"226\" \/><\/p>\n<p>\u6700\u540e\u6211\u4eec\u8fd8\u9700\u8981\u5728\u5de5\u7a0b\u9009\u9879\u91cc\u6dfb\u52a0\u4e0a\u8fd9\u4e2a\u6587\u4ef6\u5939\u7684\u5934\u6587\u4ef6\u8def\u5f84\uff0c\u8981\u4e0d\u7136\u8f6f\u4ef6\u662f\u627e\u4e0d\u5230.h\u6587\u4ef6\u7684\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-228\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/1-6.png\" alt=\"\" width=\"1160\" height=\"814\" \/><\/p>\n<h3>\u65b0\u5efamain\u51fd\u6570<\/h3>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u65b0\u5efa\u4e00\u4e2amain\u51fd\u6570\uff0c\u770b\u770b\u8fd9\u4e2a\u5de5\u7a0b\u662f\u4e0d\u662f\u53ef\u884c\uff0c\u6253\u5f00\u5de5\u7a0b\u6587\u4ef6\u5939\uff0c\u65b0\u5efa\u4e00\u4e2aUser\u6587\u4ef6\u5939\uff0cmain\u51fd\u6570\u5c31\u653e\u5728\u8fd9\u4e2a\u6587\u4ef6\u5939\u91cc\u3002<\/p>\n<p>\u8f6c\u5230Keil\u8f6f\u4ef6\u4e2d\uff0c\u5728Target\u8fd9\u91cc\u53f3\u952e\uff0c\u70b9\u51fb\u6dfb\u52a0\u7ec4\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-230\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/1-7.png\" alt=\"\" width=\"297\" height=\"152\" \/><\/p>\n<p>\u66f4\u6539\u65b0\u5efa\u7684\u7ec4\u540d\u53eb\u505aUser\uff0c\u5728User\u4e0a\u53f3\u952e\uff0c\u6dfb\u52a0\u65b0\u6587\u4ef6\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-231\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/1-8.png\" alt=\"\" width=\"342\" height=\"103\" \/><\/p>\n<p>\u4e0b\u9762\u8def\u5f84\u8981\u6ce8\u610f\u4e00\u4e0b\uff0c\u8981\u9009\u62e9User\u6587\u4ef6\u5939\uff0c\u8981\u4e0d\u7136\u9ed8\u8ba4\u653e\u5728\u6587\u4ef6\u5939\u5916\u9762\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-233\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/1-9.png\" alt=\"\" width=\"495\" height=\"314\" \/><\/p>\n<h3>\u5199\u4ee3\u7801\uff08\u5bc4\u5b58\u5668\u64cd\u4f5c\uff09<\/h3>\n<p>&nbsp;<\/p>\n<pre class=\"corepress-code-pre\"><code>#include \"stm32f10x.h\"\r\n\r\nint main(void){\r\n   while(1){\r\n\r\n               }\r\n}\r\n<\/code><\/pre>\n<p>\u8fdb\u884c\u7f16\u8bd1\uff0c\u5982\u679c0\u9519\u8bef0\u8b66\u544a\uff0c\u8bf4\u660e\u6211\u4eec\u5efa\u7acb\u7684\u5de5\u7a0b\u662f\u6ca1\u95ee\u9898\u7684\u3002<\/p>\n<p>\u8fd9\u4e2a\u5de5\u7a0b\u76ee\u524d\u8fd8\u6ca1\u6709\u6dfb\u52a0STM32\u7684\u5e93\u51fd\u6570\uff0c\u6240\u4ee5\u5b83\u8fd8\u662f\u4e00\u4e2a\u57fa\u4e8e\u5bc4\u5b58\u5668\u5f00\u53d1\u7684\u5de5\u7a0b\uff0c\u5982\u679c\u4f60\u60f3\u7528\u5bc4\u5b58\u5668\u5f00\u53d1STM32\uff0c\u90a3\u5de5\u7a0b\u5efa\u5230\u8fd9\u91cc\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u914d\u7f6e\u5bc4\u5b58\u5668\u6765\u5b8c\u6210\u70b9\u706f\uff08\u63a7\u5236PC13\u53e3\u9ad8\u4f4e\u7535\u5e73\uff09\uff1a<\/p>\n<p>1.\u62ff\u51faSTM32\u6700\u5c0f\u7cfb\u7edf\u677f\u3001STLINK\u548c\u56db\u6839\u6bcd\u5bf9\u6bcd\u7684\u675c\u90a6\u7ebf\uff0c\u6309\u7167\u63d2\u9488\u4e0a\u7684\u8868\u793a\uff0c\u628a3.3V\u3001SWDIO\u3001SWCLK\u3001GND\u5bf9\u5e94\u8fde\u63a5\u597d\u3002<\/p>\n<p>2.\u6253\u5f00Keil\uff0c\u70b9\u51fb\u9b54\u672f\u68d2\uff0c\u9009\u62e9Debug\uff0c\u9009\u62e9STLINK Debug<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-237\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/1-10.png\" alt=\"\" width=\"659\" height=\"137\" \/><\/p>\n<p>\u70b9\u51fbSettings\u6309\u94ae\uff0c\u52fe\u9009Reset and Run\uff0c\u8fd9\u6837\u6211\u4eec\u4e0b\u8f7d\u7a0b\u5e8f\u540e\u4f1a\u7acb\u9a6c\u590d\u4f4d\u5e76\u6267\u884c\uff0c\u8fd9\u6837\u65b9\u4fbf\u4e00\u4e9b\u3002<\/p>\n<p>\u8fd9\u6837\u70b9\u51fbLOAD\u6309\u94ae\u5c31\u53ef\u4ee5\u5c06\u7a0b\u5e8f\u4e0b\u8f7d\u81f3STM32\u4e0a\u4e86\u3002<\/p>\n<div class=\"sc-star-plane sc-star-plane--1\"><div class=\"sc-star-plane__content\">\u7b2c\u4e00\u6b65\uff0c\u4f7f\u80fd\u65f6\u949f\u3002\u7b2c\u4e8c\u6b65\uff0c\u914d\u7f6e\u7aef\u53e3\u3002\u7b2c\u4e09\u6b65\uff0c\u4f7f\u7528PC13\u53e3\u8f93\u51fa\u6570\u636e\u3002<\/div><\/div>\n<h4>\u7b2c\u4e00\u6b65<\/h4>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u5c31\u53ef\u4ee5\u5199\u70b9\u706f\u4ee3\u7801\u4e86\uff0c\u6253\u5f00\u82af\u7247\u624b\u518c\uff0c\u9996\u5148\u7528RCC\u7684\u4e00\u4e2a\u5bc4\u5b58\u5668\u6765\u4f7f\u80fdGPIOC\u7684\u65f6\u949f\uff0cGPIO\u90fd\u662fAPB2\u7684\u5916\u8bbe\uff0c\u6240\u4ee5\u5728APB2\u5916\u8bbe\u65f6\u949f\u4f7f\u80fd\u5bc4\u5b58\u5668RCC_APB2ENR\u91cc\u9762\u914d\u7f6e\u3002\u53ef\u4ee5\u770b\u5230\u91cc\u9762\u6709\u4e2aIOPCEN,\u8fd9\u4e00\u4f4d\u5c31\u662f\u4f7f\u80fdGPIOC\u7684\u65f6\u949f\u7684\uff0cIOPCEN\u7f6e1\u5c31\u662f\u6253\u5f00GPIOC\u65f6\u949f\u3002<\/p>\n<p>\u5c06\u5bc4\u5b58\u5668RCC_APB2ENR\u91cc\u9762\u7684\u5176\u4ed6\u4f4d\u7f6e0\uff0cIOPCEN\u7f6e1\uff0c\u5c31\u662f\u53ea\u6253\u5f00GPIOC\u7684\u65f6\u949f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-238\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/1-11.png\" alt=\"\" width=\"826\" height=\"202\" \/><\/p>\n<h4>\u7b2c\u4e8c\u6b65<\/h4>\n<p>\u63a5\u4e0b\u6765\u5c31\u8be5\u914d\u7f6e\u7aef\u53e3\u4e86\uff0c\u4f7f\u7528\u7684\u662fGPIOx_CRH\u5bc4\u5b58\u5668\uff0c\u914d\u7f6e\u6210\u901a\u7528\u63a8\u633d\u8f93\u51fa\u6a21\u5f0f\uff0c\u901f\u5ea6\u4e3a50MHz\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-239\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/1-12.png\" alt=\"\" width=\"833\" height=\"289\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-240\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/1-13.png\" alt=\"\" width=\"743\" height=\"447\" \/><\/p>\n<p>\u5373CNF13\u4e3a00\uff0cMODE13\u4e3a11\uff0c\u6362\u621016\u8fdb\u5236\u5c31\u662f0x00300000\u3002<\/p>\n<h4>\u7b2c\u4e09\u6b65<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-241\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/1-14.png\" alt=\"\" width=\"860\" height=\"385\" \/><\/p>\n<p>ODR13\u4e3a1\u5219PC13\u7aef\u53e3\u4e3a\u9ad8\u7535\u5e73\uff0c\u53cd\u4e4b\u5219\u4e3a\u4f4e\u7535\u5e73\u3002<\/p>\n<p>ODR13\u4e3a1\uff0c\u5219GPIOx_ODR\u5bc4\u5b58\u5668\u7684\u503c\u4e3a0x00002000\u3002<\/p>\n<p>ODR13\u4e3a0\uff0c\u5219GPIOx_ODR\u5bc4\u5b58\u5668\u7684\u503c\u4e3a0x00000000\u3002<\/p>\n<p>\u706f\u662f\u4f4e\u7535\u5e73\u70b9\u4eae\u7684\uff0c\u6240\u4ee5ODR\u5168\u4e3a0\u5219\u662f\u70b9\u4eae\uff0c\u4e3a0x00002000\u5219\u706d\u3002<\/p>\n<pre class=\"corepress-code-pre\"><code>#include \"stm32f10x.h\"\r\n\r\nint main(void){\r\n\tRCC-&gt;APB2ENR = 0X00000010; \/\/\u4f7f\u80fdGPIOC\u3002\r\n\tGPIOC-&gt;CRH = 0X00300000;\/\/\u914d\u7f6ePC13\u7aef\u53e3\r\n\tGPIOC-&gt;ODR = 0X00000000;\/\/\u8f93\u51faPC\u53e3\u4e3a\u4f4e\u7535\u5e73\uff0c\u706f\u70b9\u4eae\r\n\twhile(1){\r\n\t\r\n\t}\r\n}\r\n<\/code><\/pre>\n<p>\u8fd9\u5c31\u662f\u4f7f\u7528\u5bc4\u5b58\u5668\u70b9\u706f\u7684\u64cd\u4f5c\uff0c\u9700\u8981\u4e0d\u65ad\u5730\u67e5\u624b\u518c\u4e86\u89e3\u5bc4\u5b58\u5668\u6bcf\u4e00\u4f4d\u662f\u5e72\u5565\u7684\uff0c\u800c\u4e14\u8fd9\u4e2a\u64cd\u4f5c\u65b9\u5f0f\u6709\u4e2a\u5f0a\u7aef\uff0c\u5c31\u662f\u628a\u9664\u4e86PC13\u4e4b\u5916\u7684\u4f4d\u90fd\u914d\u7f6e\u6210\u4e860\uff0c\u8fd9\u6837\u5c31\u5f71\u54cd\u5230\u4e86\u5176\u4ed6\u7aef\u53e3\u7684\u539f\u6709\u914d\u7f6e\uff0c\u5982\u679c\u8981\u505a\u5230\u53ea\u914d\u7f6ePC13\u800c\u4e0d\u5f71\u54cd\u5176\u4ed6\u4f4d\uff0c\u5219\u9700\u8981&amp;=\u548c|=\u7684\u64cd\u4f5c\uff0c\u6240\u4ee5\u5bc4\u5b58\u5668\u65b9\u5f0f\u64cd\u4f5c\uff0c\u867d\u7136\u4ee3\u7801\u7b80\u6d01\uff0c\u4f46\u662f\u4e0d\u592a\u65b9\u4fbf\u3002<\/p>\n<p>&nbsp;<\/p>\n<h3>\u5199\u4ee3\u7801\uff08\u5e93\u51fd\u6570\u64cd\u4f5c\uff09<\/h3>\n<p>\u6253\u5f00\u5de5\u7a0b\u6587\u4ef6\u5939\uff0c\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6\u5939\uff0c\u53ebLibrary\uff0c\u7528\u6765\u5b58\u653e\u5e93\u51fd\u6570\u3002<\/p>\n<p>\u6253\u5f00\u56fa\u4ef6\u5e93\uff0c\u56fa\u4ef6\u5e93\\Libraries\\STM32F10x_StdPeriph_Driver\\src\uff0c\u8fd9\u91cc\u9664\u4e86misc\u662f\u5185\u6838\u5e93\u51fd\u6570\uff0c\u5176\u4ed6\u90fd\u662f\u5185\u6838\u5916\u7684\u5916\u8bbe\u5e93\u51fd\u6570\u3002\u5c06\u56fa\u4ef6\u5e93\u4e0b\u7684\u5e93\u51fd\u6570\u653e\u5165Library\u4e2d\u3002<\/p>\n<p>\u518d\u6253\u5f00\u56fa\u4ef6\u5e93\uff0c\u56fa\u4ef6\u5e93\\Libraries\\STM32F10x_StdPeriph_Driver\\inc\uff0c\u8fd9\u91cc\u662f\u5e93\u51fd\u6570\u7684\u5934\u6587\u4ef6\uff0c\u5c06\u8fd9\u4e9b\u5e93\u51fd\u6570\u7684\u5934\u6587\u4ef6\u4e5f\u653e\u5165Library\u4e2d\u3002<\/p>\n<p>\u8fd4\u56deKeil\u8f6f\u4ef6\uff0c\u65b0\u5efa\u7ec4\uff0c\u6539\u540dLibrary\uff0c\u6dfb\u52a0\u6587\u4ef6\uff0c\u9b54\u672f\u68d2\u6dfb\u52a0\u5934\u6587\u4ef6\u8def\u5f84\u3002<\/p>\n<p>\u6253\u5f00\u56fa\u4ef6\u5e93\uff0c\u56fa\u4ef6\u5e93\\Project\\STM32F10x_StdPeriph_Template\uff0c\u91cc\u9762\u6709conf(configuration)\u6587\u4ef6\u662f\u7528\u6765\u914d\u7f6e\u5e93\u51fd\u6570\u5934\u6587\u4ef6\u7684\u5305\u542b\u5173\u7cfb\u7684\uff0c\u53e6\u5916\u8fd9\u91cc\u8fd8\u6709\u4e2a\u7528\u6765\u53c2\u6570\u68c0\u67e5\u7684\u51fd\u6570\u5b9a\u4e49\uff0c\u8fd9\u662f\u6240\u6709\u5e93\u51fd\u6570\u90fd\u9700\u8981\u7684\u3002\u4e24\u4e2ait\u6587\u4ef6\u4f7f\u7528\u5b58\u653e\u4e2d\u65ad\u51fd\u6570\u7684\uff0c\u628a\u8fd9\u4e09\u4e2a\u6587\u4ef6\u590d\u5236\u4e0b\u6765\uff0c\u7c98\u8d34\u5230\u5de5\u7a0bUser\u76ee\u5f55\u4e0b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-246\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/1-15.png\" alt=\"\" width=\"190\" height=\"71\" \/><\/p>\n<p>\u8fd4\u56dekeil\u8f6f\u4ef6\uff0c\u5728User\u7ec4\u91cc\uff0c\u628a\u8fd9\u4e09\u4e2a\u6587\u4ef6\u6dfb\u52a0\u3002<\/p>\n<p>\u6700\u540e\u8fd8\u9700\u8981\u4e00\u4e2a\u5b8f\u5b9a\u4e49\uff0c\u4f60\u5b9a\u4e49\u4e86\u4f7f\u7528USE_STDPERIPH_DRIVER\u8fd9\u4e2a\u5b57\u7b26\u4e32\uff0c #include &#8220;stm32f10x_conf.h&#8221;\u8fd9\u4e2a\u5b57\u7b26\u4e32\u624d\u6709\u6548\u3002\u8fd9\u6837\u624d\u80fd\u5305\u542b\u6807\u51c6\u5916\u8bbe\u5e93\uff0c\u4e5f\u5c31\u662f\u5e93\u51fd\u6570\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-247\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/1-16.png\" alt=\"\" width=\"388\" height=\"270\" \/><\/p>\n<p>\u8fd9\u6837\u57fa\u4e8e\u5e93\u51fd\u6570\u7684\u5de5\u7a0b\u5c31\u5efa\u597d\u4e86\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\u4f7f\u7528\u5e93\u51fd\u6570\u6765\u8fdb\u884c\u70b9\u706f\u64cd\u4f5c\u3002<\/p>\n<pre class=\"corepress-code-pre\"><code>#include \"stm32f10x.h\"\r\n\r\nint main(void){\r\n\tRCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);\/\/\u4f7f\u80fdGPIOC\r\n\tGPIO_InitTypeDef GPIO_InitStructure; \/\/\u914d\u7f6e\u7aef\u53e3\u7ed3\u6784\u4f53\r\n\tGPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;\r\n\tGPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;\r\n\tGPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;\r\n\tGPIO_Init(GPIOC,&amp;GPIO_InitStructure);\r\n\/\/\tGPIO_SetBits(GPIOC,GPIO_Pin_13); \/\/\u63a7\u5236PC13\u7aef\u53e3\u7684\u9ad8\u4f4e\u7535\u5e73\r\n\tGPIO_ResetBits(GPIOC,GPIO_Pin_13);\r\n\twhile(1){\r\n\t\r\n\t}\r\n}\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u81f3\u6b64\uff0c\u672c\u8282\u65b0\u5efa\u5de5\u7a0b\u5df2\u5706\u6ee1\u7ed3\u675f\u3002<\/p>\n<h2>\u5de5\u7a0b\u67b6\u6784<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-252\" src=\"https:\/\/aoofoo.com\/wp-content\/uploads\/2024\/06\/1-18.png\" alt=\"\" width=\"882\" height=\"513\" \/><\/p>\n<p>\u8fd9\u4e2a\u56fe\u4fbf\u662f\u5de5\u7a0b\u67b6\u6784\u7684\u7ed3\u6784\u56fe\uff0c\u9996\u5148\u662fstartup\u542f\u52a8\u6587\u4ef6\uff08\u542f\u52a8\u6587\u4ef6\u4f7f\u7528\u6c47\u7f16\u8bed\u8a00\uff09\uff0c\u8fd9\u4e2a\u662f\u7a0b\u5e8f\u6267\u884c\u6700\u57fa\u672c\u7684\u6587\u4ef6\uff0c\u542f\u52a8\u6587\u4ef6\u5185\u5b9a\u4e49\u4e86\u4e2d\u65ad\u5411\u91cf\u8868\uff0c\u4e2d\u65ad\u670d\u52a1\u51fd\u6570\u7b49\uff0c\u5176\u4e2d\u4e2d\u65ad\u51fd\u6570\u670d\u52a1\u4e2d\u6709\u4e2a\u590d\u4f4d\u4e2d\u65ad\uff0c\u8fd9\u5c31\u662f\u6574\u4e2a\u7a0b\u5e8f\u7684\u5165\u53e3\u3002<\/p>\n<p>\u5f53STM32\u4e0a\u7535\u590d\u4f4d\u6216\u8005\u6309\u4e0b\u590d\u4f4d\u952e\u4e4b\u540e\uff0c\u7a0b\u5e8f\u5c31\u4f1a\u8fdb\u5165\u590d\u4f4d\u4e2d\u65ad\u51fd\u6570\u6267\u884c\uff0c\u590d\u4f4d\u4e2d\u65ad\u51fd\u6570\u4e3b\u8981\u5c31\u505a\u4e24\u4ef6\u4e8b\u60c5\uff0c\u7b2c\u4e00\u4e2a\u662f\u8c03\u7528SystemInit\u51fd\u6570\uff0c\u7b2c\u4e8c\u4e2a\u662f\u8c03\u7528main\u51fd\u6570\u3002<\/p>\n<p>\u6211\u4eec\u53ea\u9700\u77e5\u9053\uff0c\u5728main\u51fd\u6570\u6267\u884c\u4e4b\u524d\uff0c\u5355\u7247\u673a\u5df2\u7ecf\u6267\u884c\u4e86\u4e00\u5806\u4e1c\u897f\u4e86\uff0c\u5e2e\u6211\u4eec\u628a\u95ea\u5b58\u63a5\u53e3\u3001\u65f6\u949f\u7b49\u4e00\u7cfb\u5217\u6742\u788e\u7684\u4e1c\u897f\u90fd\u914d\u7f6e\u597d\u4e86\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u542f\u52a8\u6587\u4ef6\u8fd8\u5b9a\u4e49\u4e86STM32\u6240\u6709\u7684\u5176\u4ed6\u4e2d\u65ad\uff0c\u8fd9\u4e9b\u4e2d\u65ad\u8fbe\u5230\u89e6\u53d1\u6761\u4ef6\u540e\u5c31\u4f1a\u81ea\u52a8\u6267\u884c\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5bfc\u8bed \u76ee\u524dSTM32\u7684\u5f00\u53d1\u65b9\u5f0f\u4e3b\u8981\u662f\u6709\u57fa\u4e8e\u5bc4\u5b58\u5668\u7684\u65b9\u5f0f\u3001\u57fa\u4e8e\u6807\u51c6\u5e93(\u5e93\u51fd\u6570)\u7684\u65b9\u5f0f\u3001\u57fa\u4e8eHAL\u5e93\u7684\u65b9\u5f0f\u3002 \u57fa\u4e8e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-109","post","type-post","status-publish","format-standard","hentry","category-stm32"],"_links":{"self":[{"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/posts\/109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/comments?post=109"}],"version-history":[{"count":17,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/posts\/109\/revisions"}],"predecessor-version":[{"id":253,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/posts\/109\/revisions\/253"}],"wp:attachment":[{"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/media?parent=109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/categories?post=109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aoofoo.com\/index.php\/wp-json\/wp\/v2\/tags?post=109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}