CAN外设初始化-基本参数 01.禁用时间触发、使用软件的方式来决定自动离线和自动唤醒、禁止报文自动重传; 02.接收FIFO锁定,当前接收报文未读出时,下一个报文将被丢弃; 03.发送优先级由发送强求顺序决定; 04.CAN模式设置为正常模式:CAN_NORMAL_MODE; 05.CAN波特率被设置为1M,32M/((1+7+8)*2)= 1M; CAN_Reset(CAN);
CAN_Structure_Initializes(&CAN_InitStructure);
/* CAN cell init */
CAN_InitStructure.TTCM = DISABLE; //禁用时间触发通信模式
CAN_InitStructure.ABOM = DISABLE; //自动离线模式选择软件确定
CAN_InitStructure.AWKUM = DISABLE; //自动唤醒模式选择软件确定
CAN_InitStructure.NART = DISABLE; //禁止报文自动重传
CAN_InitStructure.RFLM = DISABLE; //接收FIFO锁定,当前接收报文未读出时,下一个接收到报文将被丢弃
CAN_InitStructure.TXFP = ENABLE; //发送优先级由发送请求的顺序决定
CAN_InitStructure.OperatingMode = CAN_NORMAL_MODE;
/* Baud rate calculation = CAN clock/(BaudRatePrescaler*(TBS1+TBS2+1)) */
CAN_InitStructure.RSJW = CAN_RSJW_1TQ;
CAN_InitStructure.TBS1 = CAN_TBS1_8TQ;
CAN_InitStructure.TBS2 = CAN_TBS2_7TQ;
CAN_InitStructure.BaudRatePrescaler = 2;
/*Initializes the CAN */
CAN_Initializes(CAN, &CAN_InitStructure);
涉及相关寄存器如下:
|