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.
Hello!
I am using "RM46L852".
I must use the receive interrupt of CAN communication.
However, I did not get the results I wanted.
"HALCOGEN" is used to set as below,
I checked the contents of "can.c, can.h, sys_vim.c, and sys_vim.h" in the generated code and copied the related parts to my project.
Please let me know if you have any files you need to check in addition to the above mentioned files.
If you have an example that uses receive interrupts, please share. I think that will help me.
Hello Wooyonng,
Your HALCoGen configuration looks good, it should generate CAN driver (can.c) with ISR as:
#pragma CODE_STATE(can1LowLevelInterrupt, 32)
#pragma INTERRUPT(can1LowLevelInterrupt, IRQ)
/* SourceId : CAN_SourceId_021 */
/* DesignId : CAN_DesignId_019 */
/* Requirements : HL_SR221, HL_SR223 */
void can1LowLevelInterrupt(void)
{
uint32 messageBox = canREG1->INT >> 16U;
/* USER CODE BEGIN (44) */
/* USER CODE END */
/** - Setup IF1 for clear pending interrupt flag */
/*SAFETYMCUSW 28 D MR:NA <APPROVED> "Potentially infinite loop found - Hardware Status check for execution sequence" */
while ((canREG1->IF1STAT & 0x80U) ==0x80U)
{
} /* Wait */
canREG1->IF1CMD = 0x08U;
/*SAFETYMCUSW 93 S MR: 6.1,6.2,10.1,10.2,10.3,10.4 <APPROVED> "LDRA Tool issue" */
canREG1->IF1NO = (uint8) messageBox;
/*SAFETYMCUSW 28 D MR:NA <APPROVED> "Potentially infinite loop found - Hardware Status check for execution sequence" */
while ((canREG1->IF1STAT & 0x80U) ==0x80U)
{
} /* Wait */
canREG1->IF1CMD = 0x87U;
canMessageNotification(canREG1, messageBox);
/* USER CODE BEGIN (45) */
/* USER CODE END */
In your main function, please enable IRQ interrupt using:
_enable_interrupt_();
or
_enable_IRQ();
The HALCoGen has a CAN example using interrupt:
Thank you for answer.
I checked it by adding a breakpoint to the "void can1LowLevelInterrupt (void)" function, but it does not enter this function.
However, when the following function is executed in the main function, the value comes in Rx Data.
Can1RxID = canGetID(canREG1, canMESSAGE_BOX5);
//while(!canIsRxMessageArrived(canREG1, canMESSAGE_BOX5));
canGetData(canREG1, canMESSAGE_BOX5, canRxData);
Also, when you uncomment "// while (! CanIsRxMessageArrived (canREG1, canMESSAGE_BOX5));", you will end up in an infinite loop here.
Communication is normally performed, but no interruption occurs.
I think there is a problem with the interrupt settings, but I do not know which part.