Bug in FlexCAN drivers for PXN20 on MQX 4.1

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Bug in FlexCAN drivers for PXN20 on MQX 4.1

406 Views
hbouch
Contributor III

Hi,

There is a bug in the FlexCAN driver for PXN20 in MQX 4.1. The FlexCAN example seems to work fine but in fact, it's not. The ISR is called only because the Tx interrupt is enabled, Rx interrupt doesn't work. The Tx interrupt sets the event with the IFLAG register value (in which the bit of the Rx buffer is set). If you disable it, the ISR is not called anymore, the event is not set and the Rx task waits forever.

the interrupts are not setup properly by the driver. Actually, if you look at the following function, vector_index variable is divided by 4!!! In the example, Rx message buffer is 1 so 1/4 = 0. The interrupt that is setup is the interrupt for message buffer 0 and not 1...

PSP_INTERRUPT_TABLE_INDEX _bsp_get_flexcan_vector

(

    /* [IN] FlexCAN device number */

     uint8_t  dev_num,

    /* [IN] FlexCAN interrupt vector type */

     uint8_t  vector_type,

    /* [IN] FlexCAN interrupt vector index */

     uint32_t vector_index

)

{

    PSP_INTERRUPT_TABLE_INDEX index = (PSP_INTERRUPT_TABLE_INDEX) 0;

    if ((FLEXCAN_INT_BUF==vector_type) && (31>=vector_index)) {

         vector_index = vector_index>>2;

    } else if (0 != vector_index) {

         return 0;

    }

    switch (dev_num)

    {

            case 0:

                 switch (vector_type)

                 {

                      case FLEXCAN_INT_BUF:

                          index = MPXN20_INTC_FLEXCAN_A_BUF_0_VECTOR+vector_index;

                          break;

                      case FLEXCAN_INT_ERR:

                          index = MPXN20_INTC_FLEXCAN_A_ERROR_VECTOR;

                          break;

                      case FLEXCAN_INT_BOFF:

                          index = MPXN20_INTC_FLEXCAN_A_BUS_OFF_WARN_VECTOR;

                          break;

                      default:

                          break;

                 }

                 break;

             case 1:

                  switch (vector_type)

                  {

                       case FLEXCAN_INT_BUF:

                           index = MPXN20_INTC_FLEXCAN_B_BUF_0_VECTOR+vector_index;

                           break;

                       case FLEXCAN_INT_ERR:

                           index = MPXN20_INTC_FLEXCAN_B_ERROR_VECTOR;

                           break;

                       case FLEXCAN_INT_BOFF:

                           index = MPXN20_INTC_FLEXCAN_B_BUS_OFF_WARN_VECTOR;

                           break;

                       default:

                           break;

                  }

                  break;

             case 2:

(...)

The lines in red above need to be commented out. Only a check if vector_index is not out of range should be done.

Hugo

0 Kudos
1 Reply

237 Views
RadekS
NXP Employee
NXP Employee

Hi Hugo,

Thank you very much for your bug report.

It seems that you are right.

I do not see any reason for line "vector_index = vector_index>>2;"

I will report our internal bug database.


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos