问答

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

zzqssq

TA的家园币:12  

  • hc32f460 can导致单片机复位

    can使能后发送数据,如果can总线上没有其他节点接收数据,单片机直接重启。接上接收设备后,单片机正常工作。can配置代码如下//CANConfigstaticvoidApp_CANCfg(void){stc_can_init_tstcCanInit;/*************************ConfigureCAN1***************************/stc_can_filter_config_tastcFilter1[1U]={{0x1UL,0x0000UL,CAN_ID_STD},};/*InitializesCAN.*/(void)CAN_StructInit(&stcCanInit);stcCanInit.stcBitCfg.u32Prescaler=12U;stcCanInit.stcBitCfg.u32TimeSeg1=5U;stcCanInit.stcBitCfg.u32TimeSeg2=3;stcCanInit.stcBitCfg.u32SJW=3;stcCanInit.pstcFilter=astcFilter1;stcCanInit.u16FilterSelect=CAN_FILTER1;stcCanInit.u8WorkMode=CAN_WORK_MD_NORMAL;//CAN_WORK_MD_ELB;stcCanInit.u8PTBSingleShotTx=CAN_PTB_SINGLESHOT_TX_ENABLE;stcCanInit.u8STBSingleShotTx=CAN_STB_SINGLESHOT_TX_ENABLE;stcCanInit.u8STBPrioMode=CAN_STB_PRIO_MD_DISABLE;stcCanInit.u8RxWarnLimit=10U;stcCanInit.u8ErrorWarnLimit=15U;stcCanInit.u8RxAllFrame=CAN_RX_ALL_FRAME_DISABLE;stcCanInit.u8RxOvfMode=CAN_RX_OVF_DISCARD_NEW;stcCanInit.u8SelfAck=CAN_SELF_ACK_DISABLE;/*EnableperipheralclockofCAN.*/FCG_Fcg1PeriphClockCmd(FCG1_PERIPH_CAN,ENABLE);(void)CAN_Init(CM_CAN,&stcCanInit);CAN_ExitLocalReset(CM_CAN);/*Enabletheinterrupts,thestatusflagscanberead.*/CAN_IntCmd(CM_CAN,CAN_INT_ALL,DISABLE);CAN_IntCmd(CM_CAN,CAN_INT_ERR_INT|CAN_INT_RX_BUF_WARN|CAN_INT_RX|CAN_INT_BUS_ERR,ENABLE);}