在学习nxp1768,,在编程中出现HardFault_Handler,,程序运行就死在.s文件的HardFault_Handler上了,不知什么原因。程序是对的,求解
一下是程序,调用这个程序,就出现错误
void CAN_SendMessage( uint32_t CanNum,CAN_MSG *pTxBuf )
{
uint32_t CANStatus,CANStatus2;
CANStatus = LPC_CAN1->SR;
CANStatus2 = LPC_CAN2->SR;
switch(CanNum)
{
case 1:
if ( CANStatus & 0x00000004 )
{
LPC_CAN1->TFI1 = pTxBuf->Frame & 0xC00F0000;
LPC_CAN1->TID1 = pTxBuf->MsgID;
LPC_CAN1->TDA1 = pTxBuf->DataA;
LPC_CAN1->TDB1 = pTxBuf->DataB;
LPC_CAN1->CMR = 0x21;
}
else if ( CANStatus & 0x00000400 )
{
LPC_CAN1->TFI2 = pTxBuf->Frame & 0xC00F0000;
LPC_CAN1->TID2 = pTxBuf->MsgID;
LPC_CAN1->TDA2 = pTxBuf->DataA;
LPC_CAN1->TDB2 = pTxBuf->DataB;
LPC_CAN1->CMR = 0x41;
}
else if ( CANStatus & 0x00040000 )
{
LPC_CAN1->TFI3 = pTxBuf->Frame & 0xC00F0000;
LPC_CAN1->TID3 = pTxBuf->MsgID;
LPC_CAN1->TDA3 = pTxBuf->DataA;
LPC_CAN1->TDB3 = pTxBuf->DataB;
LPC_CAN1->CMR = 0x81;
}
break;
case 2:
if ( CANStatus2 & 0x00000004 )
{
LPC_CAN2->TFI1 = pTxBuf->Frame & 0xC00F0000;
LPC_CAN2->TID1 = pTxBuf->MsgID;
LPC_CAN2->TDA1 = pTxBuf->DataA;
LPC_CAN2->TDB1 = pTxBuf->DataB;
LPC_CAN2->CMR = 0x21;
}
else if ( CANStatus2 & 0x00000400 )
{
LPC_CAN2->TFI2 = pTxBuf->Frame & 0xC00F0000;
LPC_CAN2->TID2 = pTxBuf->MsgID;
LPC_CAN2->TDA2 = pTxBuf->DataA;
LPC_CAN2->TDB2 = pTxBuf->DataB;
LPC_CAN2->CMR = 0x41;
}
else if ( CANStatus2 & 0x00040000 )
{
LPC_CAN2->TFI3 = pTxBuf->Frame & 0xC00F0000;
LPC_CAN2->TID3 = pTxBuf->MsgID;
LPC_CAN2->TDA3 = pTxBuf->DataA;
LPC_CAN2->TDB3 = pTxBuf->DataB;
LPC_CAN2->CMR = 0x81;
}
break;
}
}
此帖出自
小平头技术问答
一周热门 更多>