21ic问答首页 - GD32F103RB映射UART0到PB6,PB7失败怎么解决?
GD32F103RB映射UART0到PB6,PB7失败怎么解决?
wanzhilin882021-08-30
我在作用GD32F103RB时,LQFP64将串口0重映射到PB6,PB7时串口发送数据时无输出。用示波器测量IO口无波形。但是串口中断可以进去。
PB6 - Remap: USART_RX
PB7 - Remap: USART_TX
//初始化程序如下:
nvic_irq_enable(USART0_IRQn, 14, 0); //
// remap uart0
rcu_periph_clock_enable(RCU_AF);
gpio_pin_remap_config(GPIO_USART0_REMAP,ENABLE);
/* enable GPIO clock */
rcu_periph_clock_enable( RCU_GPIOB); // clock already seted
rcu_periph_clock_enable( RCU_GPIOB);
/* connect port to USARTx_Tx */
gpio_init(GPIOB, GPIO_MODE_OUT_OD, GPIO_OSPEED_2MHZ, GPIO_PIN_6);
/* connect port to USARTx_Rx */
gpio_init(GPIOB, GPIO_MODE_OUT_OD, GPIO_OSPEED_2MHZ, GPIO_PIN_7);
/* enable USART clock */
rcu_periph_clock_enable(RCU_USART0);
/* USART configure */
usart_deinit(USART0);
usart_baudrate_set(USART0, 9600);
usart_word_length_set(USART0, USART_WL_8BIT);
usart_stop_bit_set(USART0, USART_STB_1BIT);
usart_parity_config(USART0, USART_PM_NONE);
usart_hardware_flow_rts_config(USART0, USART_RTS_DISABLE);
usart_hardware_flow_cts_config(USART0, USART_CTS_DISABLE);
usart_receive_config(USART0, USART_RECEIVE_ENABLE);
usart_transmit_config(USART0, USART_TRANSMIT_ENABLE);
usart_enable(USART0);
// interrupt enable
//usart_interrupt_enable(USART0, USART_INT_TBE);
PB6 - Remap: USART_RX
PB7 - Remap: USART_TX
//初始化程序如下:
nvic_irq_enable(USART0_IRQn, 14, 0); //
// remap uart0
rcu_periph_clock_enable(RCU_AF);
gpio_pin_remap_config(GPIO_USART0_REMAP,ENABLE);
/* enable GPIO clock */
rcu_periph_clock_enable( RCU_GPIOB); // clock already seted
rcu_periph_clock_enable( RCU_GPIOB);
/* connect port to USARTx_Tx */
gpio_init(GPIOB, GPIO_MODE_OUT_OD, GPIO_OSPEED_2MHZ, GPIO_PIN_6);
/* connect port to USARTx_Rx */
gpio_init(GPIOB, GPIO_MODE_OUT_OD, GPIO_OSPEED_2MHZ, GPIO_PIN_7);
/* enable USART clock */
rcu_periph_clock_enable(RCU_USART0);
/* USART configure */
usart_deinit(USART0);
usart_baudrate_set(USART0, 9600);
usart_word_length_set(USART0, USART_WL_8BIT);
usart_stop_bit_set(USART0, USART_STB_1BIT);
usart_parity_config(USART0, USART_PM_NONE);
usart_hardware_flow_rts_config(USART0, USART_RTS_DISABLE);
usart_hardware_flow_cts_config(USART0, USART_CTS_DISABLE);
usart_receive_config(USART0, USART_RECEIVE_ENABLE);
usart_transmit_config(USART0, USART_TRANSMIT_ENABLE);
usart_enable(USART0);
// interrupt enable
//usart_interrupt_enable(USART0, USART_INT_TBE);
赞0
评论
2021-08-30
赞0
评论
2021-08-30
您需要登录后才可以回复 登录 | 注册