新手入门
- 积分
- 17
- 金钱
- 17
- 注册时间
- 2021-12-30
- 在线时间
- 4 小时
|
3金钱
在工程中,只有一个RS485串口,使用USART3的RS485串口程序移植成功,能够接收和发送,想加入USMART功能,于是想将USART.C加入对RS485 RX/TX转换的端口控制,具体做法如下:
- void uart_init(u32 bound){
- //GPIO端口设置
- GPIO_InitTypeDef GPIO_InitStructure;
- USART_InitTypeDef USART_InitStructure;
- NVIC_InitTypeDef NVIC_InitStructure;
- RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); //使能USART3,GPIOA时钟
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC, ENABLE); //使能USART3,GPIOB/C时钟
- //USART3_TX PB10 GPIO_Mode_AF_PP;
- …………
-
- //USART3_RX PB11 GPIO_Mode_IN_FLOATING
- …………
-
- //加入PC8RX/TX控制
- GPIO_InitStructure.GPIO_Pin=GPIO_Pin_8;
- GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
- GPIO_Init(GPIOC,&GPIO_InitStructure);
- PBout(8)=0;//默认接收
- }
复制代码 我希望在每次printf()函数使用时都加入:
- PBout(8)=1;
- printf();
- PBout(8)=0;
复制代码 来切换485块的输入输出,但是无论怎么设置,都是printf函数能够输出,但是我想输入,输入中断始终进不去。
不知道自己错在哪里还是485就不能这么用,请大神指教。
|
|