-
GD32F103收发485通讯不进中断,收怎么也不行中断
/*enableUSARTandGPIOAclock*/rcu_periph_clock_enable(RCU_GPIOB);rcu_periph_clock_enable(RCU_USART2);gpio_pin_remap_config(GPIO_USART2_PARTIAL_REMAP,ENABLE);//引脚重映射gpio_init(GPIOB,GPIO_MODE_OUT_PP,GPIO_OSPEED_50MHZ,GPIO_PIN_1);gpio_bit_reset(GPIOB,GPIO_PIN_1);/*configureUSART2Txasalternatefunctionpush-pull*/gpio_init(GPIOB,GPIO_MODE_AF_PP,GPIO_OSPEED_50MHZ,GPIO_PIN_10);/*configureUSART2Rxasalternatefunctionpush-pull*/gpio_init(GPIOB,GPIO_MODE_IN_FLOATING,GPIO_OSPEED_50MHZ,GPIO_PIN_11);voidinitUART(){/*USARTinterruptconfiguration*/nvic_priority_group_set(NVIC_PRIGROUP_PRE1_SUB3);nvic_irq_enable(USART2_IRQn,1,1);/*configureCOM0*///gd_eval_com_init(EVAL_COM0);usart_baudrate_set(USART2,115200U);usart_parity_config(USART2,USART_PM_NONE);//无奇偶检验usart_word_length_set(USART2,USART_WL_8BIT);//8位数据usart_stop_bit_set(USART2,USART_STB_1BIT);//一个停止位usart_hardware_flow_rts_config(USART2,USART_RTS_DISABLE);//无硬件数据流usart_hardware_flow_cts_config(USART2,USART_CTS_DISABLE);//硬件流控制CTSusart_receive_config(USART2,USART_RECEIVE_ENABLE);//串口接收usart_transmit_config(USART2,USART_TRANSMIT_ENABLE);//串口发送//usart_halfduplex_enable(USART2);usart_interrupt_enable(USART2,USART_INT_RBNE);usart_enable(USART2);}voidUART2_IRQHandler(void){staticintdataLen=0;dataRev=0x11;if(SET==usart_interrupt_flag_get(USART2,USART_INT_FLAG_TBE)){usart_interrupt_flag_clear(USART2,USART_INT_FLAG_TBE);/*transmitdata*/usart_data_transmit(USART2,txbuffer[txcount++]);if(txcount==tx_size){usart_interrupt_disable(USART2,USART_INT_TBE);gpio_bit_reset(GPIOB,GPIO_PIN_1);}}if((SET==usart_interrupt_flag
2023-12-25 0 -
极海APM32F030 读正交编码器 引脚GPIO模式设置成什么模式?
读取正交编码器输入,GPIO引脚配置成什么模式?GPIO_MODE_AF还是GPIO_MODE_IN?
2023-09-21 21