CH32V203 中 CAN 在测试模式中,比如开启静默环回模式。重新进入初始化模式,对寄存器 CAN_BTIMR 的 SILM 和 LBKM 位置0(寄存器置0成功),退出初始化模式,静默环回模式依旧存在,需重新上下电才能恢复,请问这是特性吗?
/* 官方程序 */ uint8_t CAN_Init(CAN_TypeDef* CANx, CAN_InitTypeDef* CAN_InitStruct) { uint8_t InitStatus = CAN_InitStatus_Failed; uint32_t wait_ack = 0x00000000; CANx->CTLR &= (~(uint32_t)CAN_CTLR_SLEEP); CANx->CTLR |= CAN_CTLR_INRQ ; while (((CANx->STATR & CAN_STATR_INAK) != CAN_STATR_INAK) && (wait_ack != INAK_TIMEOUT)) { wait_ack++; } if ((CANx->STATR & CAN_STATR_INAK) != CAN_STATR_INAK) { InitStatus = CAN_InitStatus_Failed; } else { if (CAN_InitStruct->CAN_TTCM == ENABLE) { CANx->CTLR |= CAN_CTLR_TTCM; } else { CANx->CTLR &= ~(uint32_t)CAN_CTLR_TTCM; } if (CAN_InitStruct->CAN_ABOM == ENABLE) { CANx->CTLR |= CAN_CTLR_ABOM; } else { CANx->CTLR &= ~(uint32_t)CAN_CTLR_ABOM; } if (CAN_InitStruct->CAN_AWUM == ENABLE) { CANx->CTLR |= CAN_CTLR_AWUM; } else { CANx->CTLR &= ~(uint32_t)CAN_CTLR_AWUM; } if (CAN_InitStruct->CAN_NART == ENABLE) { CANx->CTLR |= CAN_CTLR_NART; } else { CANx->CTLR &= ~(uint32_t)CAN_CTLR_NART; } if (CAN_InitStruct->CAN_RFLM == ENABLE) { CANx->CTLR |= CAN_CTLR_RFLM; } else { CANx->CTLR &= ~(uint32_t)CAN_CTLR_RFLM; } if (CAN_InitStruct->CAN_TXFP == ENABLE) { CANx->CTLR |= CAN_CTLR_TXFP; } else { CANx->CTLR &= ~(uint32_t)CAN_CTLR_TXFP; } CANx->BTIMR = (uint32_t)((uint32_t)CAN_InitStruct->CAN_Mode << 30) | \ ((uint32_t)CAN_InitStruct->CAN_SJW << 24) | \ ((uint32_t)CAN_InitStruct->CAN_BS1 << 16) | \ ((uint32_t)CAN_InitStruct->CAN_BS2 << 20) | \ ((uint32_t)CAN_InitStruct->CAN_Prescaler - 1); CANx->CTLR &= ~(uint32_t)CAN_CTLR_INRQ; wait_ack = 0; while (((CANx->STATR & CAN_STATR_INAK) == CAN_STATR_INAK) && (wait_ack != INAK_TIMEOUT)) { wait_ack++; } if ((CANx->STATR & CAN_STATR_INAK) == CAN_STATR_INAK) { InitStatus = CAN_InitStatus_Failed; } else { InitStatus = CAN_InitStatus_Success ; } } return InitStatus; }