欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
STM32使用USART1沒什么問題,使用USART3就是搞不出來 也不知程序哪里錯了
[打印本頁]
作者:
zhangpeng12345
時間:
2021-11-4 10:47
標題:
STM32使用USART1沒什么問題,使用USART3就是搞不出來 也不知程序哪里錯了
求一個stm32f103rct6使用USART3收發數據的歷程,不勝感激!!!
void USART3_init(u32 bound)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); //??USART3,GPIOB??
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); //??USART3,GPIOB??
USART_DeInit(USART3); //????3
//USART3_TX PB10
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; //PB10
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //??????
GPIO_Init(GPIOB, &GPIO_InitStructure); //???Pb10
//USART3_RX PB11
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;//????
GPIO_Init(GPIOB, &GPIO_InitStructure); //???PB11
//Usart1 NVIC ??
NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=1 ;//?????3
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //????3
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ????
NVIC_Init(&NVIC_InitStructure); //??????????VIC???
//USART ?????
USART_InitStructure.USART_BaudRate = bound;//?????115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;//???8?????
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_Rx | USART_Mode_Tx; //????
USART_Init(USART3, &USART_InitStructure); //?????
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);//??USART3????
USART_Cmd(USART3, ENABLE); //????
}
作者:
黃youhui
時間:
2021-11-5 11:08
USART3_RX引腳沒有復用
51hei截圖20211105110814.png
(96.99 KB, 下載次數: 74)
下載附件
2021-11-5 11:08 上傳
作者:
AUG
時間:
2021-11-5 14:06
去找原子或者野火的demo自己搗鼓他們的USART1的初始化就知道了,或者百度隨便找個例程也很多,對比下就知道了。
作者:
zyluglugl
時間:
2021-11-8 06:36
我在工程應用的初始化函數給你:2樓是正解,學習了:
void USART3_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
/* 使能 USART3 時鐘*/
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);//使能外設時鐘
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 ;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
/* USART3 使用IO端口配置 */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //復用推挽輸出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //浮空輸入
GPIO_Init(GPIOB, &GPIO_InitStructure); //初始化GPIOA
/* USART3 工作模式配置 */
USART_InitStructure.USART_BaudRate = 19200; //波特率設置:19200 步進電機的通訊率
USART_InitStructure.USART_WordLength = USART_WordLength_8b; //數據位數設置:8位
USART_InitStructure.USART_StopBits = USART_StopBits_1; //停止位設置:1位
USART_InitStructure.USART_Parity = USART_Parity_No ; //是否奇偶校驗:無
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; //硬件流控制模式設置:沒有使能
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;//接收與發送都使能
USART_Init(USART3, &USART_InitStructure); //初始化USART3
/*使能串口3的發送和接收中斷*/
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
USART_Cmd(USART3, ENABLE);// USART3使能
}
作者:
plb1213
時間:
2021-11-27 18:49
這樣改行不行
void USART3_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
/* 使能 USART3 時鐘*/
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);//使能外設時鐘
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 ;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
/* USART3 使用IO端口配置 */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //復用推挽輸出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //浮空輸入
GPIO_Init(GPIOB, &GPIO_InitStructure); //初始化GPIOA
/* USART3 工作模式配置 */
USART_InitStructure.USART_BaudRate = 19200; //波特率設置:19200 步進電機的通訊率
USART_InitStructure.USART_WordLength = USART_WordLength_8b; //數據位數設置:8位
USART_InitStructure.USART_StopBits = USART_StopBits_1; //停止位設置:1位
USART_InitStructure.USART_Parity = USART_Parity_No ; //是否奇偶校驗:無
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; //硬件流控制模式設置:沒有使能
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;//接收與發送都使能
USART_Init(USART3, &USART_InitStructure); //初始化USART3
/*使能串口3的發送和接收中斷*/
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
USART_Cmd(USART3, ENABLE);// USART3使能
}
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1