[KW36] ConfigTools v8 - Error creating peripherals.c

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

[KW36] ConfigTools v8 - Error creating peripherals.c

507 Views
acarles
Contributor I

Hi,

I am using a FRDM-KW36 NXP Board. I am trying to configure some basic things like PIT, CAN, etc.

My IDE is IAR but I use MCUXpresso ConfigTools Version 8.0 to set the pinout, the clock settings and peripherals information. I think that the CAN code create by default with this tool have some errors:

peripherals.c - ConfigTools

 

 

/* Message buffer 0 configuration structure */
const flexcan_rx_mb_config_t CAN0_rx_mb_config_0 = {
  .id = 0x132UL,
  .format = kFLEXCAN_FrameFormatStandard,
  .type = kFLEXCAN_FrameTypeData
};

static void CAN0_init(void) {
  FLEXCAN_Init(CAN0_PERIPHERAL, &CAN0_config, CAN0_CLOCK_SOURCE);

  /* Message buffer 0 initialization */
  FLEXCAN_SetRxMbConfig(CAN0_PERIPHERAL, 0, &CAN0_rx_mb_config_0, true);
  /* Message buffer 1 initialization */
  FLEXCAN_SetTxMbConfig(CAN0_PERIPHERAL, 1, true);
  /* Enable FlexCAN interrupts of message buffers */
  FLEXCAN_EnableMbInterrupts(CAN0_PERIPHERAL, 1UL);
  /* Enable interrupt CAN0_IRQn request in the NVIC. */
  EnableIRQ(CAN0_FLEXCAN_IRQN);
}

 

 

In CAN0_rx_mb_config_0 the id is set to 0x132UL but the correct format should be FLEXCAN_ID_STD(0x123). If I don't change it only detects the 0x000 messages.

In the EnableIRQ it set the variable CAN0_FLEXCAN_IRQN which is an alias of CAN0_IRQn. However, the FLEXCAN_EnableMbInterrupts() interacts withCAN0_MB_IRQn.

Finally, in peripherals.h is defined:

 

 

/* CAN0 interrupt vector ID (number). */
#define CAN0_FLEXCAN_IRQN CAN0_IRQn
/* CAN0 interrupt handler identifier. */
#define CAN0_FLEXCAN_IRQHANDLER CAN0_IRQHandler

 

 

 But CAN0_IRQHandler is not the correct handle for this interrupt. It must be CAN0_MB_IRQHandler.

Anyone else have the same problems?

 

 
0 Kudos
Reply
0 Replies