-
hc32f460 can导致单片机复位
can使能后发送数据,如果can总线上没有其他节点接收数据,单片机直接重启。接上接收设备后,单片机正常工作。can配置代码如下 //CAN Config static void App_CANCfg(void) { stc_can_init_t stcCanInit; /************************* Configure CAN1***************************/ stc_can_filter_config_t astcFilter1[1U] = { {0x1UL, 0x0000UL, CAN_ID_STD}, }; /* Initializes CAN. */ (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; /* Enable peripheral clock of CAN. */ FCG_Fcg1PeriphClockCmd(FCG1_PERIPH_CAN, ENABLE); (void)CAN_Init(CM_CAN, &stcCanInit); CAN_ExitLocalReset(CM_CAN); /* Enable the interrupts, the status flags can be read. */ 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); }
4764浏览量 13回复量 关注量