Announcements

Robots are revolutionizing our lives in many ways. Join our webinar to learn about Infineon’s broad portfolio of robot building blocks.
Click here to register.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

AURIX™ Forum Discussions

ATY
Level 1
Level 1
5 replies posted 10 sign-ins 5 sign-ins

Hi Community,

I want to generate an interrupt using a high priority message (FRAME or CAN signal with specific ID), I followed the steps that are defined in the user manual .

the problem is that I get an interrupt when receiving all the frames sent on the bus, not a specific can frame

I followed this step to config canfilter and interrupt 

• At least one Standard Message ID Filter Element is configured with priority
flag set (S0.SFEC = “100”/”101”/”110”)
• No Extended Message ID Filter Element configured
• Non-matching extended frames are accepted (GFC.ANFE = “00”/”01”)
The HPM interrupt flag IR.HPM is set erroneously on reception of a non-highpriority extended message under the following conditions:
1. A standard HPM frame is received, and accepted by a filter with priority flag
set
--> Interrupt flag IR.HPM is set as expected
2. Next an extended frame is received and accepted because of GFC.ANFE
configuration
--> Interrupt flag IR.HPM is set erroneously

 

void CANIsrHighPriorityMsgMCMCAN(void)
{
   /* Clear the "Transmission Completed" interrupt flag */
   IfxCan_Node_clearInterruptFlag(g_mcmcan.can00Node.node, IfxCan_Interrupt_highPriorityMessage);
}
 
   //High Priority Message Interrupt
   g_mcmcan.canNodeConfig.interruptConfig.highPriorityMessageEnabled = TRUE;
   g_mcmcan.canNodeConfig.interruptConfig.hpe.priority = ISR_PRIORITY_CAN_MSG_HIGH_PRIORITY;
   g_mcmcan.canNodeConfig.interruptConfig.hpe.interruptLine = IfxCan_InterruptLine_4;
   g_mcmcan.canNodeConfig.interruptConfig.hpe.typeOfService = IfxSrc_Tos_cpu0;
 
  g_mcmcan.canFilter.number = 0;
   g_mcmcan.canFilter.elementConfiguration = IfxCan_FilterElementConfiguration_setPriorityAndStoreInFifo0;
   g_mcmcan.canFilter.type = IfxCan_FilterType_classic;
   g_mcmcan.canFilter.id1 = 0x23 ; // ( ID of the frame that used to generated the interrupt) ;
   g_mcmcan.canFilter.rxBufferOffset = IfxCan_RxBufferId_0;
   IfxCan_Can_setStandardFilter(&(g_mcmcan.can00Node), &(g_mcmcan.canFilter));
 
Please, Do you have any idea to help me.
 
Thank you and best regards,
0 Likes
5 Replies
dw
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 100 likes received

For MCMCAN Filtering, there is a code here. There are three ISR routines for RxBuffer and RxFifo0/1.

Below code is to describe how to initialize three ISRs. You can modified the code according your requirement.

 

{
 /* ------------------------------------------------------------------------------------------
     * General filter configuration
     * ------------------------------------------------------------------------------------------
     *  - General filter configuration should be valid for both standard and extended ID messages
     *  - Define number of standard ID filter elements
     *  - Define number of extended ID filter elements
     *  - Accept non-matching messages with standard IDs and store them to RX FIFO 1
     *  - Reject non-matching messages with extended IDs
     *  - Reject remote frames with standard IDs
     *  - Reject remote frames with extended IDs
     * ------------------------------------------------------------------------------------------
     */
    g_mcmcan.canNodeConfig.filterConfig.messageIdLength = IfxCan_MessageIdLength_both;
    g_mcmcan.canNodeConfig.filterConfig.standardListSize = NUMBER_OF_STND_ID_FILTERS;
    g_mcmcan.canNodeConfig.filterConfig.extendedListSize = NUMBER_OF_EXTD_ID_FILTERS;
    g_mcmcan.canNodeConfig.filterConfig.standardFilterForNonMatchingFrames = IfxCan_NonMatchingFrame_acceptToRxFifo1;
    g_mcmcan.canNodeConfig.filterConfig.extendedFilterForNonMatchingFrames = IfxCan_NonMatchingFrame_reject;
    g_mcmcan.canNodeConfig.filterConfig.rejectRemoteFramesWithStandardId = TRUE;
    g_mcmcan.canNodeConfig.filterConfig.rejectRemoteFramesWithExtendedId = TRUE;

    /* ------------------------------------------------------------------------------------------
     * Interrupt configuration
     * ------------------------------------------------------------------------------------------
     *  - Once the message is stored in the dedicated RX buffer/RX FIFO 0/RX FIFO 1, raise an interrupt
     *  - Define the reception interrupt priority (1/2/3)
     *  - Assign the interrupt line 1/2/3 to the reception interrupt
     *  - Reception interrupt service routine should be serviced by the CPU0
     * ------------------------------------------------------------------------------------------
     */
    g_mcmcan.canNodeConfig.interruptConfig.messageStoredToDedicatedRxBufferEnabled = TRUE;
    g_mcmcan.canNodeConfig.interruptConfig.reint.priority = ISR_PRIORITY_CAN_RX_BUFFER;
    g_mcmcan.canNodeConfig.interruptConfig.reint.interruptLine = IfxCan_InterruptLine_1;
    g_mcmcan.canNodeConfig.interruptConfig.reint.typeOfService = IfxSrc_Tos_cpu0;

    g_mcmcan.canNodeConfig.interruptConfig.rxFifo0NewMessageEnabled = TRUE;
    g_mcmcan.canNodeConfig.interruptConfig.rxf0n.priority = ISR_PRIORITY_CAN_RX_FIFO_0;
    g_mcmcan.canNodeConfig.interruptConfig.rxf0n.interruptLine = IfxCan_InterruptLine_2;
    g_mcmcan.canNodeConfig.interruptConfig.rxf0n.typeOfService = IfxSrc_Tos_cpu0;

    g_mcmcan.canNodeConfig.interruptConfig.rxFifo1NewMessageEnabled = TRUE;
    g_mcmcan.canNodeConfig.interruptConfig.rxf1n.priority = ISR_PRIORITY_CAN_RX_FIFO_1;
    g_mcmcan.canNodeConfig.interruptConfig.rxf1n.interruptLine = IfxCan_InterruptLine_3;
    g_mcmcan.canNodeConfig.interruptConfig.rxf1n.typeOfService = IfxSrc_Tos_cpu0;

    /* ------------------------------------------------------------------------------------------
     * Initialization of the destination CAN node with the modified configuration
     * ------------------------------------------------------------------------------------------
     */
    IfxCan_Can_initNode(&g_mcmcan.canDstNode, &g_mcmcan.canNodeConfig);

    /* ------------------------------------------------------------------------------------------
     * Initialization of standard and extended ID filter elements
     * ==========================================================================================
     */
    for(currentFilterElement = 0; currentFilterElement < NUMBER_OF_STND_ID_FILTERS; currentFilterElement++)
    {
        IfxCan_Can_setStandardFilter(&g_mcmcan.canDstNode, &g_filterStandardIdConfiguration[currentFilterElement]);
    }
    for(currentFilterElement = 0; currentFilterElement < NUMBER_OF_EXTD_ID_FILTERS; currentFilterElement++)
    {
        IfxCan_Can_setExtendedFilter(&g_mcmcan.canDstNode, &g_filterExtendedIdConfiguration[currentFilterElement]);
    }
}

 

0 Likes
ATY
Level 1
Level 1
5 replies posted 10 sign-ins 5 sign-ins

Hi DW,

Thank you for your feedback.

I think I was not too clear, I'm sorry DW

I have several frames that transit on the CAN bus, and I trigger an interrupt when a new message is received, but I want to trigger an interrupt when a specific frame ID is received ( stored in fifo memory).

Example, to trigger an interrupt when I receive a frame with ID = 10 which will be a high priority interrupt

Thank you and best regards,

0 Likes
dw
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 100 likes received

If use the filter demo , you can ignore or disable one ISR, and leave other ISR to process the frame ID you wanted. Is it possible?

ATY
Level 1
Level 1
5 replies posted 10 sign-ins 5 sign-ins

I wanted to keep the interrupt that processes all new messages received (flag rxFifo0NewMessageEnabled) and I want to add another interrupt with a higher priority that processes a high priority message (flag highPriorityMessageEnabled) and that triggers just at the reception of a specific message, I know it's possible but I don't know how I generate an interrupt at the reception of a very specific message

0 Likes
dw
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 100 likes received

As above showed, there are three ISR routines for RxBuffer and RxFifo0/1. I suggest to utilize this already existing mechanism to realize your purpose.

0 Likes
This widget could not be displayed.