本帖最后由 xx3360765 于 2017-8-22 16:25 编辑
以下是我的代码程序烧录到板上后一点反应都没有,串口通讯助手也一点反应都没有。求解救。
/////////////usart.c#include "stm32f10x.h"#include "stm32f10x_gpio.h"#include "stm32f10x_rcc.h"#include "stm32f10x_usart.h"#include "misc.h"#include "usart.h"#define RS485_DIR_TX GPIO_WriteBit(GPIOA,GPIO_Pin_9,1);#define RS485_DIR_RX GPIO_WriteBit(GPIOA,GPIO_Pin_9,0);void USART1_Initial(void){ GPIO_InitTypeDef GPIO_InitStructure2; USART_InitTypeDef USART_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO,ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE); //????PA,USART1?????±?? GPIO_InitStructure2.GPIO_Pin = GPIO_Pin_9 ; GPIO_InitStructure2.GPIO_Speed = GPIO_Speed_50MHz; //50M?±?????? GPIO_InitStructure2.GPIO_Mode = GPIO_Mode_Out_PP; //???ì???? GPIO_Init(GPIOA, &GPIO_InitStructure2); GPIO_InitStructure2.GPIO_Pin = GPIO_Pin_10; //485_TXD GPIO_InitStructure2.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure2.GPIO_Mode = GPIO_Mode_AF_PP; //???????ì???? GPIO_Init(GPIOA, &GPIO_InitStructure2); GPIO_InitStructure2.GPIO_Pin = GPIO_Pin_11; //485_RXD GPIO_InitStructure2.GPIO_Mode = GPIO_Mode_IN_FLOATING; //???????? GPIO_Init(GPIOA, &GPIO_InitStructure2); NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=3 ;//??????????3 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //×???????3 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ?¨?????? NVIC_Init(&NVIC_InitStructure); //?ù?????¨????????????VIC?????÷ USART_InitStructure.USART_BaudRate = 9600; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx; USART_Init(USART1, &USART_InitStructure); USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);//???????????????? USART_Cmd(USART1, ENABLE); RS485_DIR_RX;}/////////////main.c#include "gpio.h"#include "usart.h"#include "stm32f10x.h"#include "stm32f10x_gpio.h"#include "stm32f10x_rcc.h"#include "stm32f10x_usart.h"int main(void){ SystemInit(); GPIO_Initial(); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); USART1_Initial(); RS485_DIR_TX; while(1) { USART_SendData(USART1, 55); }}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
我也很好奇,原理图不是我画的。
一周热门 更多>