-
GD32F103C8T6 SPI做从机可以接收数据,但是不能发送数据出去
GD32F103C8T6SPI做从机,中断可以接收数据,但是不能发送数据出去,使用的模式是全双工,有遇到过这种吗?我用另外一个GD32F205的芯片,做SPI从机就是可以同时收发的,这个芯片就是发不出来,我对了一下官方的例程,没有发现代码问题在哪,代码如下/***@briefSPI_FLASH初始化*@param无*@retval无*/voidBSP_SPI_Init(void){spi_parameter_structspi_init_struct;#ifndefSPI_MODE_MASTER/*configureSPI1NVIC*/nvic_irq_enable(SPI1_IRQn,1,3);#endif/*SPIclockenable*/rcu_periph_clock_enable(RCU_GPIOB);rcu_periph_clock_enable(RCU_SPI1);/*SPI1GPIOconfig*/#ifdefSPI_MODE_MASTER//MASTER//CSgpio_init(SPI1_CS_PORT,GPIO_MODE_OUT_PP,GPIO_OSPEED_50MHZ,SPI1_CS_PIN);//SCKMOSIgpio_init(SPI1_SCK_PORT,GPIO_MODE_AF_PP,GPIO_OSPEED_50MHZ,SPI1_SCK_PIN);gpio_init(SPI1_MOSI_PORT,GPIO_MODE_AF_PP,GPIO_OSPEED_50MHZ,SPI1_MOSI_PIN);//MISOgpio_init(SPI1_MISO_PORT,GPIO_MODE_AF_PP,GPIO_OSPEED_50MHZ,SPI1_MISO_PIN);#else//SLAVE//CSgpio_init(SPI1_CS_PORT,GPIO_MODE_IN_FLOATING,GPIO_OSPEED_50MHZ,SPI1_CS_PIN);//SCKMOSIgpio_init(SPI1_SCK_PORT,GPIO_MODE_IN_FLOATING,GPIO_OSPEED_50MHZ,SPI1_SCK_PIN);gpio_init(SPI1_MOSI_PORT,GPIO_MODE_AF_PP,GPIO_OSPEED_50MHZ,SPI1_MOSI_PIN);//MISOgpio_init(SPI1_MISO_PORT,GPIO_MODE_AF_PP,GPIO_OSPEED_50MHZ,SPI1_MISO_PIN);#endif/*chipselectinvalid*/gpio_bit_write(SPI1_CS_PORT,SPI1_CS_PIN,SET);/*deinitilizeSPIandtheparameters*/spi_i2s_deinit(SPI1);spi_struct_para_init(&spi_init_struct);/*SPI1parameterconfig*/spi_init_struct.trans_mode=SPI_TRANSMODE_FULLDUPLEX;#ifdefSPI_MODE_MASTERspi_init_struct.device_mode=SPI_MASTER;spi_init_struct.clock_polarity_phase=SPI_CK_PL_HIGH_PH_2EDGE;#elsespi_init_struct.device_mode=SPI_SLAVE;spi
2022-01-15 3 -
GD32F103C8T6 CAN没有输出
GD32F103C8T6CAN没有输出回环模式,可以读取回数据,但是我重映射的PB8,PB9没有信号出来,外接的TJA1050,请问有遇到类似问题的吗?代码如下can_trasnmit_message_structtransmit_message;can_receive_message_structreceive_message;uint8_tCAN_Tx_Buf[8];uint8_tCAN_Rx_Buf[8];/*!\briefinitializeCANandfilter\paramcan_parameter\argcan_parameter_struct\paramcan_filter\argcan_filter_parameter_struct\param[out]none\retvalnone*/voidBSP_CANInit(void){can_parameter_structcan_parameter;can_filter_parameter_structcan_filter;/*configureCAN0NVIC*/nvic_irq_enable(USBD_LP_CAN0_RX0_IRQn,1,2);/*enableCANclock*/rcu_periph_clock_enable(RCU_CAN0);rcu_periph_clock_enable(RCU_GPIOB);rcu_periph_clock_enable(RCU_AF);/*configureCAN0GPIO*/gpio_pin_remap_config(GPIO_CAN_FULL_REMAP,ENABLE);gpio_init(GPIOB,GPIO_MODE_IPU,GPIO_OSPEED_50MHZ,GPIO_PIN_8);gpio_init(GPIOB,GPIO_MODE_AF_PP,GPIO_OSPEED_50MHZ,GPIO_PIN_9);/*initializeCANandfilter*/can_struct_para_init(CAN_INIT_STRUCT,&can_parameter);can_struct_para_init(CAN_FILTER_STRUCT,&can_filter);/*initializeCANregister*/can_deinit(CAN0);/*initializeCANparameters*/can_parameter.time_triggered=DISABLE;//TTC时间触发通信0:禁用时间触发通信1:使能时间触发通信can_parameter.auto_bus_off_recovery=DISABLE;//ABOR自动离线恢复0:通过软件手动地从离线状态恢复1:通过硬件自动的从离线状态恢复can_parameter.auto_wake_up=DISABLE;//AWK自动唤醒0:通过软件手动的从睡眠工作模式唤醒1:通过硬件自动的从睡眠工作模式唤醒can_parameter.no_auto_retrans=ENABLE;//DISABLE;//ARD自动重发禁止0:使能自动重发1:禁用自动重发can_parameter.rec_fifo_overwrite=DISABLE;//RFOD禁用接收FIFO满时覆盖0:使能接收FIFO满时覆盖1:禁用接收FIF
2022-01-15 1