问答

汇集网友智慧,解决技术难题

编号10086

TA的家园币:262  

  • GD32F150C8T6配置USART1不成功

    #defineEVAL_COM1USART1#defineEVAL_COM1_CLKRCU_USART1#defineEVAL_COM1_TX_PINGPIO_PIN_2//PA2#defineEVAL_COM1_RX_PINGPIO_PIN_3//PA3#defineEVAL_COM_GPIO_PORTGPIOA#defineEVAL_COM_GPIO_CLKRCU_GPIOA#defineEVAL_COM_AFGPIO_AF_1voidgd_eval_com_init(uint32_tCOM){uint32_tCOM_ID=0U;if(EVAL_COM1==COM){COM_ID=0U;}rcu_periph_clock_enable(RCU_GPIOA);//USART时钟使能rcu_periph_clock_enable(RCU_USART1);//配置TX为推挽复用模式gpio_mode_set(GPIOA,GPIO_MODE_AF,GPIO_PUPD_PULLUP,GPIO_PIN_2);gpio_output_options_set(EVAL_COM_GPIO_PORT,GPIO_OTYPE_PP,GPIO_OSPEED_10MHZ,GPIO_PIN_2);//配置RX为浮空输入模式gpio_mode_set(GPIOA,GPIO_MODE_AF,GPIO_PUPD_PULLUP,GPIO_PIN_3);gpio_output_options_set(EVAL_COM_GPIO_PORT,GPIO_OTYPE_PP,GPIO_OSPEED_10MHZ,GPIO_PIN_3);usart_deinit(USART1);usart_baudrate_set(USART1,9600U);//波特率usart_word_length_set(USART1,USART_WL_8BIT);//帧数据字长usart_stop_bit_set(USART1,USART_STB_1BIT);//停止位usart_parity_config(USART1,USART_PM_NONE);//奇偶校验位usart_hardware_flow_rts_config(USART1,USART_RTS_DISABLE);//硬件流控制RTSusart_hardware_flow_cts_config(USART1,USART_CTS_DISABLE);//硬件流控制CTSusart_receive_config(USART1,USART_RECEIVE_ENABLE);//使能接收usart_transmit_config(USART1,USART_TRANSMIT_ENABLE);//使能发送usart_enable(USART1);nvic_irq_enable(USART1_IRQn,0,1);//使能串口接收中断usart_interrupt_enable(USART1,USART_INT_RBNE);usart_interrupt_enable(USART1,USART_INT_TBE);}voidUSART0_IRQHandler(void){if(RESET!=usart_interrupt_flag_get(EVAL_COM1,USART_INT_FLAG_RBNE)){/*receivedata*/receiver_buffer[rxcount++]=usart_data_receive(EVAL_COM1);if(rxcount==receivesize){//usart_interrupt_disable(EV

  • 使用上海芯旺微电子KF32F330MCU下载程序失败

    不管是源码下载还是HEX下载出现“校验FLASHSPACE失败,芯片中非当前代码程序!334F9C64D378714DDB64AF3CD2F679E8”下载失败问题。(PS:以前是下进去过的,因为更新程序要重新下载就出现这个问题)