404CAN通信中断进不去!!!!
![了然唔_fZE07](https://hz-rm-bbs-web-prod.oss-cn-hangzhou.aliyuncs.com/avatar/pre/v1/default.png)
如题。折腾好些天了,can通信一直不能发送出去信息,通过仿真看到中断函数根本就没进去,有哪位大神能解答我之心忧,感激涕零[img=0,1]file:///C:/Users/13jfzhang/AppData/Roaming/Tencent/Users/472183109/QQ/WinTemp/RichOle/S~D3B(NS%7DQBN62LZ9[EWM6I.png[/img][img=0,1]file:///C:/Users/13jfzhang/AppData/Roaming/Tencent/Users/472183109/QQ/WinTemp/RichOle/S~D3B(NS%7DQBN62LZ9[EWM6I.png[/img]!!!void CAN1_TX_IRQHandler(void){
if (CAN_GetITStatus(CAN1,CAN_IT_TME)!= RESET)
{
CAN_ClearITPendingBit(CAN1,CAN_IT_TME);
can_tx_success_flag=1;
}
}
void CAN1_SEND(unsigned char CAN_ID,int PWM_Value)
{
CanTxMsg tx_message;
tx_message.IDE = CAN_ID_STD; //标准帧
tx_message.RTR = CAN_RTR_DATA; //数据帧
tx_message.DLC = 0x08; //帧长度为8
tx_message.StdId = CAN_ID; //帧ID为传入参数的CAN_ID
tx_message.Data[0] = (unsigned char)(PWM_Value&0xff);
tx_message.Data[1] = (unsigned char)((PWM_Value>>8)&0xff);
tx_message.Data[2] = (unsigned char)((PWM_Value>>16)&0xff);
tx_message.Data[3] = 0x55;
tx_message.Data[4] = 0x55;
tx_message.Data[5] = 0x55;
tx_message.Data[6] = 0x55;
tx_message.Data[7] = 0x55;
can_tx_success_flag = 0;
CAN_Transmit(CAN1,&tx_message);
while(can_tx_success_flag == 0);
}
if (CAN_GetITStatus(CAN1,CAN_IT_TME)!= RESET)
{
CAN_ClearITPendingBit(CAN1,CAN_IT_TME);
can_tx_success_flag=1;
}
}
void CAN1_SEND(unsigned char CAN_ID,int PWM_Value)
{
CanTxMsg tx_message;
tx_message.IDE = CAN_ID_STD; //标准帧
tx_message.RTR = CAN_RTR_DATA; //数据帧
tx_message.DLC = 0x08; //帧长度为8
tx_message.StdId = CAN_ID; //帧ID为传入参数的CAN_ID
tx_message.Data[0] = (unsigned char)(PWM_Value&0xff);
tx_message.Data[1] = (unsigned char)((PWM_Value>>8)&0xff);
tx_message.Data[2] = (unsigned char)((PWM_Value>>16)&0xff);
tx_message.Data[3] = 0x55;
tx_message.Data[4] = 0x55;
tx_message.Data[5] = 0x55;
tx_message.Data[6] = 0x55;
tx_message.Data[7] = 0x55;
can_tx_success_flag = 0;
CAN_Transmit(CAN1,&tx_message);
while(can_tx_success_flag == 0);
}
请问这篇文章对你有用吗?
404CAN通信中断进不去!!!!