stm32 can好几天都调试不通,请各位高手指点一下,谢谢

2019-03-23 18:52发布

测试环境:stm32+ISO1050 接stm32+ISO1050,相当于连个stm32对接

stm32 can好几天都调试不通,更奇怪,打印一些错误信息,竟然显示没有错误,各位高手指点,谢谢

当把两个stm32之间can线缆接上时,检查错误打印信息是没有错误,消息一直pengding状态,但是又没有显示错误
TxMessage.StdId =0x00 0x01
TxMessage.ExtId =0x12 0x34
TxMessage.RTR =0x00
TxMessage.IDE =0x00
TxMessage.DLC =0x02
TxMessage.Data =0x01 0x02
Mail box is ok
message send pending
CAN_FLAG_BOF = RESET
CAN_FLAG_EWG = RESET
CAN_FLAG_EPV = RESET
message send pending
CAN_FLAG_BOF = RESET
CAN_FLAG_EWG = RESET
CAN_FLAG_EPV = RESET
message send pending
CAN_FLAG_BOF = RESET
CAN_FLAG_EWG = RESET
CAN_FLAG_EPV = RESET

当把两个stm32之间can线缆断开时,检查错误打印信息是有错误的,消息一直pengding状态
TxMessage.StdId =0x00 0x01
TxMessage.ExtId =0x12 0x34
TxMessage.RTR =0x00
TxMessage.IDE =0x00
TxMessage.DLC =0x02
TxMessage.Data =0x01 0x02
Mail box is ok
message send pending
CAN_FLAG_BOF = RESET
CAN_FLAG_EWG = SET
CAN_FLAG_EPV = SET
message send pending
CAN_FLAG_BOF = RESET
CAN_FLAG_EWG = SET
CAN_FLAG_EPV = SET
message send pending
CAN_FLAG_BOF = RESET
CAN_FLAG_EWG = SET
CAN_FLAG_EPV = SET


代码如下:
TransmitMailbox = CAN_Transmit(CAN1,&TxMessage);
    if(CAN_NO_MB == TransmitMailbox)
    {
        //发送失败,没有空邮箱
        PUT("Mail box is nok ");
        return 0;
    }
    else
    {
        PUT("Mail box is ok ");
        CAN_msg_num[TransmitMailbox] = 1;   
    }
    do
    {
        message_tx_status = CAN_TransmitStatus(CAN1, TransmitMailbox);
         if(message_tx_status == CANTXOK)
         {
             PUT("message send ok ");
         }
         else if(message_tx_status == CANTXPENDING)   
        {
            PUT("message send pending ");
        }
         else if(message_tx_status == CANTXFAILED)   
        {
            PUT("message send failed ");
        }
         delay_GSM(10000);
         retry_time++;
         Status_sign = CAN_GetFlagStatus(CAN1,CAN_FLAG_BOF);
         if(Status_sign == SET)
         {
             PUT("CAN_FLAG_BOF = SET ");
             CAN1->MCR|=1;
            CAN1->MCR&=0xfffffffe;
         }
         else
         {
             PUT("CAN_FLAG_BOF = RESET ");
         }
         Status_sign = CAN_GetFlagStatus(CAN1,CAN_FLAG_EWG);
         if(Status_sign == SET)
         {
             PUT("CAN_FLAG_EWG = SET ");
         }
         else
         {
             PUT("CAN_FLAG_EWG = RESET ");
         }
         Status_sign = CAN_GetFlagStatus(CAN1,CAN_FLAG_EPV);
         if(Status_sign == SET)
         {
             PUT("CAN_FLAG_EPV = SET ");
         }
         else
         {
             PUT("CAN_FLAG_EPV = RESET ");
         }
此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。