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.

HalCoGen sample code [example_canIntCommunication.c], canMessageNotification()

Other Parts Discussed in Thread: HALCOGEN

Sirs,

I have a question about the HalCoGen sample code.

[C:\ti\Hercules\HALCoGen\v03.08.01\examples\TMS570LS04x\example_canIntCommunication.c]

 

We see a C function canMessageNotification():

void canMessageNotification(canBASE_t *node, uint32 messageBox)
{
     /* node 1 - transfer request */
     if(node==canREG1)
     {    
       tx_done=1; /* confirm transfer request */
     }

     /* node 2 - receive complete */    
     if(node==canREG2)
     {
      while(!canIsRxMessageArrived(canREG2, canMESSAGE_BOX1));  //// Ln.172
      canGetData(canREG2, canMESSAGE_BOX1, rx_ptr); /* copy to RAM */   
      rx_ptr +=8;    
     }    

    /* Note: since only message box 1 is used on both nodes we dont check it here.*/
}

 

-----------------------------------------------------------------------

So my question is, why the blue colored line is required?  Or, for what the line is waiting?  (Ln.172)
Do you assume any specific case that the line is executed but the CAN received message is NOT ready to be read?

 

  • Hi Hideaki,

    The canIsRxMessageArrived function is added to check if the particular messagebox of interest has recieved a new data. Generally in a system, there could be many more message boxes configured and any one of them could have generated the receive interrupt. It is a good practise to check if the desired meesage box has received new data in that case.

    In this code, we know that only one message box is configured and hence it may not be required. It is added in a more generic sense.

    Regards,
    Praveen

  • Hello Praveen,

    Thank you for your response. So I understood that we don't have to poll the canIsRxMessageArrived() in the interrrupt service routine.