This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I am trying to implement the CAN messages interrupt. I have two Hercules RM57Lx kits. I have successfully implemented the CAN messages on both of them. I created following CAN setting using HALCOGEN
One KIT is working as the TX and other is as the RX. However, I am facing issues with interrupt-based communication. The issue is I am able to get the interrupt for the canMESSAGE_BOX1 but I fail to get interrupt when I just send the canMESSAGE_BOX2 message from TX controller to RX. Both messages are sent to RX controller which can read them but interrupt occurs for just the canMESSAGE_BOX1 controller. Also this function
canIsRxMessageArrived(canREG1, canMESSAGE_BOX1)
works fine for canMESSAGE_BOX1 and the controller can learn if there is a message in the canMESSAGE_BOX1, but when I call the function canIsRxMessageArrived(canREG1, canMESSAGE_BOX2), it always returns false. However, if I ignore it, just call
canGetData(canREG1, canMESSAGE_BOX2, rxData);
function to read the data in MessagBox2, it reads the data which I have send from TX controller perfectly fine. Code is given below. What I am missing here?
My TX code main file is
int main(void)
{
/* USER CODE BEGIN (3) */
unsigned long int index;
canInit();
while (1)
{
canTransmit(canREG1, canMESSAGE_BOX1, (const uint8 *) &txData[0]);
for (index = 0; index < 4967000; index++)
{}
canTransmit(canREG1, canMESSAGE_BOX2, (const uint8 *) &LEDOn[0]);
for (index = 0; index < 4967000; index++)
{}
}
}
RX Code :
int main(void)
{
/* USER CODE BEGIN (3) */
canInit();
sciInit();
vimInit();
_enable_interrupt_();
sciSend(sciREG1, 15, "Prgram starting\r");
while (1)
{
// while(!canIsRxMessageArrived(canREG1, canMESSAGE_BOX1));
while (isCANInterruptOccured == 0); //
if (canIsRxMessageArrived(canREG1, canMESSAGE_BOX1) == true)
{
canGetData(canREG1, canMESSAGE_BOX1, rxData);
sciSend(sciREG1, D_SIZE, &rxData[0]);
}
if (canIsRxMessageArrived(canREG1, canMESSAGE_BOX2) == true)
{
canGetData(canREG1, canMESSAGE_BOX2, rxData);
sciSend(sciREG1, D_SIZE, &rxData[0]);
}
isCANInterruptOccured = 0;
}
/* USER CODE END */
return 0;
}
Hello Fehan,
I'm not the CAN expert but I will try to offer some advice while we wait for the expert to respond.
Have you enabled the interrupt for CAN2 Low (#42) in the VIM Channel 32-63 tab?
Can you try using the HIGH interrupt for one CAN and LOW for the other? You will need to enable the corresponding interrupts in VIM as well.
The following resources may provide some useful pointers as well.
Configuring a CAN Node on Hercules ARM Safety MCUs
https://training.ti.com/hercules-how-tutorial-can-communication
Regards,
Sahin
Hi,
Thanks. I have resolved the issue by adding the flags in the canMessageNotification() function. And MessageBox2 interrupt is occurring as well. I really do not know what I changed which enable this. Anyway, I am resolving the issue. Thanks for the help.