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.

how to clears the interrupt of a canErrorNotification

Other Parts Discussed in Thread: TMS570LS1227, HALCOGEN

I use TMS570LS1227 for my project,when i use the can interrupt,when the can transmit err,it will enter "void canErrorNotification(canBASE_t *node, uint32 notification)",the i want to know how to clear pending interrupt flag?

  • Notification isn't the interrupt handler.
    The actual ISR is different (look for name in VIM RAM vector table and in the can.c file).

    The ISR should clear the interrupt flag and if necessary call the notification routine where you can insert application specific steps.
    In other words - the basic ISR framework including clearing flags is already done for you.
  • @Anthony F. Seely thanks,In my code i want to choise CAN1 or CAN2 to send message,When there is an error in a channel switch to another channel,But each channel error interrupts into only once,so i think maybe clears the interrupt,is there some problem?
  • if (value == 0x8000U)
    {
    /* Read Error and Status Register*/
    ES_value = canREG2->ES;

    /* Check for Error (PES, Boff, EWarn & EPass) captured */
    if((ES_value & 0x1E0U) != 0U)
    {
    canErrorNotification(canREG2, ES_value & 0x1E0U);
    }
    else
    {
    /* Call General Can notification incase of RxOK, TxOK, PDA, WakeupPnd Interrupt */
    canStatusChangeNotification(canREG2, ES_value & 0x618U);
    }
    }
    else
    {
    /** - Setup IF1 for clear pending interrupt flag */
    /*SAFETYMCUSW 28 D MR:NA <APPROVED> "Potentially infinite loop found - Hardware Status check for execution sequence" */
    while ((canREG2->IF1STAT & 0x80U) ==0x80U)
    {
    } /* Wait */

    canREG2->IF1CMD = 0x08U;
    /*SAFETYMCUSW 93 S MR: 6.1,6.2,10.1,10.2,10.3,10.4 <APPROVED> "LDRA Tool issue" */
    canREG2->IF1NO = (uint8) value;

    /*SAFETYMCUSW 28 D MR:NA <APPROVED> "Potentially infinite loop found - Hardware Status check for execution sequence" */
    while ((canREG2->IF1STAT & 0x80U) ==0x80U)
    {
    } /* Wait */
    canREG2->IF1CMD = 0x87U;

    canMessageNotification(canREG2, value);
    }

    enter mailbox will clear the interrupt trigger, but error notification will not clear,I think this is the problem I met,Cause the program into only one interrupt.How do you solve this problem?
  • Hi user4756214 ,

    Sorry I don't really understand where the problem is.

    But if I understand you want to use CAN2 as a sort of 'backup' if there is a problem detected on CAN1, is that correct?

    That is something you may need to code yourself into the ISR and application. It's not a use case that would be part of the default HalCoGen driver.
  • thanks,you are right,I met the problem is that when there is something wrong with the bus,it will only enter once fault interrupt,I want to make the system can be in when the CAN1 or CAN2 has problem, it can freely switch between them.So I need to repeatedly enter the wrong interrupts.
  • Hi user4756214,

    You probably should write your own interrupt handlers then; as this is beyond the scope of what HalCoGen provides.
    It does sound like an interesting thing though and I bet other people would be interested in knowing the solution you come up with.

    -Anthony