问答

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

fw19876311

TA的家园币:34  

  • GD32F103C8T6,使用ST标准库,CAN初始化失败

    本帖最后由fw19876311于2025-1-1417:01编辑STM32F103C8T6正常运行的代码,直接平替GD32F103C8,CAN部分初始化异常,一直返回失败uint8_tCAN_Init(CAN_TypeDef*CANx,CAN_InitTypeDef*CAN_InitStruct){uint8_tInitStatus=CAN_InitStatus_Failed;uint32_twait_ack=0x00000000;/*Checktheparameters*/assert_param(IS_CAN_ALL_PERIPH(CANx));assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_TTCM));assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_ABOM));assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_AWUM));assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_NART));assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_RFLM));assert_param(IS_FUNCTIONAL_STATE(CAN_InitStruct->CAN_TXFP));assert_param(IS_CAN_MODE(CAN_InitStruct->CAN_Mode));assert_param(IS_CAN_SJW(CAN_InitStruct->CAN_SJW));assert_param(IS_CAN_BS1(CAN_InitStruct->CAN_BS1));assert_param(IS_CAN_BS2(CAN_InitStruct->CAN_BS2));assert_param(IS_CAN_PRESCALER(CAN_InitStruct->CAN_Prescaler));/*Exitfromsleepmode*/CANx->MCR&=(~(uint32_t)CAN_MCR_SLEEP);/*Requestinitialisation*/CANx->MCR|=CAN_MCR_INRQ;/*Waittheacknowledge*/while(((CANx->MSR&CAN_MSR_INAK)!=CAN_MSR_INAK)&&(wait_ack!=INAK_TIMEOUT)){wait_ack++;}/*Checkacknowledge*/if((CANx->MSR&CAN_MSR_INAK)!=CAN_MSR_INAK){InitStatus=CAN_InitStatus_Failed;=====================卡在这个位置}请教各位,有遇到过吗?麻烦指导下,谢谢大家!

  • HK32F030MF4P6,6路PWM+SPI,SPI工作异常

    调试HK32F030MF4P6,遇到SPI工作异常的问题,把PWM初始化全部去掉,SPI接收slaver器件数据都正常,打开PWM后,SPI只在刚启动的那一下,收到正确数据,之后就再也收不到slaver的数据了,有人遇到过吗?从逻辑分析仪的波形上看,发送数据是成功了的