{"id":2601,"date":"2019-06-05T08:49:53","date_gmt":"2019-06-05T08:49:53","guid":{"rendered":""},"modified":"2019-06-05T16:50:11","modified_gmt":"2019-06-05T08:50:11","slug":"stm32%e5%8d%95%e7%89%87%e6%9c%ba%e5%a4%96%e9%83%a8%e4%b8%ad%e6%96%ad%e7%9a%84%e8%ae%be%e7%bd%ae%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"http:\/\/www.szryc.com\/?p=2601","title":{"rendered":"STM32\u5355\u7247\u673a\u5916\u90e8\u4e2d\u65ad\u7684\u8bbe\u7f6e\u65b9\u6cd5"},"content":{"rendered":"

\n\t\u6bd4\u5982\u8981\u662f\u4f7f\u7528GPC3\u4f5c\u4e3a\u4e2d\u65ad\u6e90\uff0c\u4e0a\u5347\u6cbf\u89e6\u53d1\u5916\u90e8\u4e2d\u65ad\u5fc5\u987b\u914d\u7f6e\u597dEXTI<\/u>\u548cNVIC<\/span><\/p>\n

\n\t\u4f7f\u7528\u4ee5\u4e0b\u51fd\u6570\u6253\u5f00SYSCFG\u7684\u65f6\u949f<\/u><\/p>\n

\n\t <\/div>\n

\n\tRCC_APB2PeriphClockCmd\uff08RCC_APB2Periph_SYSCFG\uff0c ENABLE\uff09<\/p>\n

\n\t\"STM32\u5355\u7247\u673a\u5916\u90e8\u4e2d\u65ad\u7684\u8bbe\u7f6e\u65b9\u6cd5\"<\/p>\n

\n\tGPI<\/u>O\u8bbe\u7f6e\u5982\u4e0b<\/p>\n

\n\tvoid GPIO_ConfiguraTIon\uff08void\uff09<\/p>\n

\n\t{<\/p>\n

\n\tGPIO_InitTypeDef GPIO_InitStructure;<\/p>\n

\n\t\/* GPIOF Periph clock enable *\/<\/p>\n

\n\tRCC_AHB1PeriphClockCmd\uff08RCC_AHB1Periph_GPIOC\uff0c ENABLE\uff09;<\/p>\n

\n\tRCC_APB2PeriphClockCmd\uff08RCC_APB2Periph_SYSCFG\uff0c ENABLE\uff09;\/\/\u6ce8\u610f\u8981\u6253\u5f00SYSCFG\u65f6\u949f<\/p>\n

\n\tGPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;<\/p>\n

\n\tGPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;<\/p>\n

\n\tGPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;<\/p>\n

\n\tGPIO_Init\uff08GPIOC\uff0c &GPIO_InitStructure\uff09;<\/p>\n

\n\t}<\/p>\n

\n\t\u56e0\u4e3a\u8981\u7528\u7684IO\u53e3\u505a\u4e2d\u65ad\u6e90\uff0c\u6545IO\u7684\u590d\u7528\u529f\u80fd\u5fc5\u987b\u4f7f\u80fd\uff0cF4\u7684\u4e0eF103\u7684\u6709\u4e9b\u4e0d\u540c\uff0c\u5b83\u7684\u5916\u90e8\u4e2d\u65ad\u590d\u7528\u529f\u80fd\u662f\u7531SYSCFG_EXTILineConfig\uff08EXTI_PortSourceGPIOx\uff0cGPIO_PinSourcex\uff09; \u8fdb\u884c\u914d\u7f6e\u7684\u3002<\/p>\n

\n\tvoid EXTI_Configuration\uff08void\uff09<\/p>\n

\n\t{<\/p>\n

\n\tEXTI_InitTypeDef EXTI_InitStructure;<\/p>\n

\n\t\/\/GPIO_EXTILineConfig\uff08GPIO_PortSourceGPIOC\uff0c GPIO_PinSource3\uff09;\/\/\u8fd9\u662f\u4ee5\u524d\u7684F103\u6240\u7528\u7684\u914d\u7f6e\u51fd\u6570<\/p>\n

\n\tSYSCFG_EXTILineConfig\uff08EXTI_PortSourceGPIOC\uff0c EXTI_PinSource3\uff09; \/\/407\u4f7f\u7528\u7684\u914d\u7f6e\u51fd\u6570<\/p>\n

\n\tEXTI_InitStructure.EXTI_Line = EXTI_Line3;<\/p>\n

\n\tEXTI_InitStructure.EXTI_Mode = EXTI_Mode_Inte<\/u>rrupt;<\/p>\n

\n\tEXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;<\/p>\n

\n\tEXTI_InitStructure.EXTI_LineCmd = ENABLE;<\/p>\n

\n\tEXTI_Init\uff08&EXTI_InitStructure\uff09;<\/p>\n

\n\t}<\/p>\n

\n\t\u8bbe\u7f6e\u5916\u90e8\u4e2d\u65ad\u6e90\u548c\u4f18\u5148\u7ea7<\/p>\n

\n\tvoid NVIC_Config\uff08void\uff09<\/p>\n

\n\t{<\/p>\n

\n\tNVIC_InitTypeDef NVIC_InitStructure;<\/p>\n

\n\t\/* Enable the USARTx Interrupt *\/<\/p>\n

\n\tNVIC_InitStructure.NVIC_IRQChannel = EXTI3_IRQn;<\/p>\n

\n\tNVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;<\/p>\n

\n\tNVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;<\/p>\n

\n\tNVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;<\/p>\n

\n\tNVIC_Init\uff08&NVIC_InitStructure\uff09;<\/p>\n

\n\t}<\/p>\n

\n\t\u4e2d\u65ad\u5904\u7406\u51fd\u6570<\/p>\n

\n\tvoid EXTI3_IRQHandler\uff08void\uff09<\/p>\n

\n\t{<\/p>\n

\n\tif\uff08EXTI_GetITStatus\uff08EXTI_Line3\uff09 \uff01= RESET\uff09<\/p>\n

\n\t{<\/p>\n

\n\tdo something\uff08\uff09;<\/p>\n

\n\tEXTI_ClearITPendingBit\uff08EXTI_Line3\uff09;<\/p>\n

\n\tprintf\uff08“EXTI3_IRQHandlerrn”\uff09;<\/p>\n

\n\t}<\/p>\n

\n\t}<\/p>\n","protected":false},"excerpt":{"rendered":"

\u6bd4\u5982\u8981\u662f\u4f7f\u7528GPC3\u4f5c\u4e3a\u4e2d\u65ad\u6e90\uff0c\u4e0a\u5347\u6cbf\u89e6\u53d1 \u5916\u90e8\u4e2d\u65ad\u5fc5\u987b\u914d\u7f6e\u597dEX TI \u548cNVIC \u4f7f\u7528\u4ee5\u4e0b\u51fd\u6570\u6253\u5f00SYSCFG\u7684 \u65f6\u949f RCC_APB2PeriphClockCmd\uff08RCC_APB2Periph_SYSCFG\uff0c ENABLE\uff09 G PI O\u8bbe\u7f6e\u5982\u4e0b void GPIO_ConfiguraTIon\uff08<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"_links":{"self":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/2601"}],"collection":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2601"}],"version-history":[{"count":0,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/2601\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2601"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2601"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}