S32K148 CAN send bug

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
6,103件の閲覧回数
347996379
Contributor III
flexcan_state_t canCom1_State;
const flexcan_user_config_t canCom1_InitConfig0 = {
 .max_num_mb = 2,                         /*!< The maximum number of Message Buffers
                                 @internal gui name="Maximum number of message buffers" id="max_num_mb" */
 .pe_clock = FLEXCAN_CLK_SOURCE_PERIPH,            /*!< The clock source of the CAN Protocol Engine (PE). */
 .is_rx_fifo_needed = false,   /*!< 1 if needed; 0 if not. This controls whether the Rx FIFO feature is enabled or not.
         @internal gui name="Use rx fifo" id="is_rx_fifo_needed" */
 .num_id_filters = FLEXCAN_RX_FIFO_ID_FILTERS_8,/*!< The number of RX FIFO ID filters needed
                                        @internal gui name="Number of RX FIFO ID filters" id="num_id_filters" */
 .fd_enable = false,    /*!< Enable/Disable the Flexible Data Rate feature. */
 .flexcanMode = FLEXCAN_LOOPBACK_MODE,            /*!< User configurable FlexCAN operation modes.
                                       @internal gui name="Flexcan Operation Mode" id="flexcanMode"*/
 .payload = FLEXCAN_PAYLOAD_SIZE_8,             /*!< The payload size of the mailboxes specified in bytes. */
 /*!< The bitrate used for standard frames or for the arbitration phase of FD frames. */  //500K
 .bitrate = {
  .propSeg = 7,   /*!< Propagation segment*/
  .phaseSeg1 = 4,  /*!< Phase segment 1*/
  .phaseSeg2 = 1,  /*!< Phase segment 2*/
  .preDivider = 0, /*!< Clock prescaler division factor*/
  .rJumpwidth = 1  /*!< Resync jump width*/
 },
 /*!< The bitrate used for the data phase of FD frames. */
 .bitrate_cbt = {
  .propSeg = 11,  /*!< Propagation segment*/
  .phaseSeg1 = 1,  /*!< Phase segment 1*/
  .phaseSeg2 = 1,  /*!< Phase segment 2*/
  .preDivider = 0, /*!< Clock prescaler division factor*/
  .rJumpwidth = 1  /*!< Resync jump width*/
 },
 .transfer_type = FLEXCAN_RXFIFO_USING_INTERRUPTS,/*!< Specifies if the Rx FIFO uses interrupts or DMA. */
 .rxFifoDMAChannel = 0U     /*!< Specifies the DMA channel number to be used for DMA transfers. */
};

/* Set information about the data to be received or sended*/
flexcan_data_info_t dataInfo =
{
 .msg_id_type = FLEXCAN_MSG_ID_EXT,/*!< Type of message ID (standard or extended)*/
 .data_length = 1U,                /*!< Length of Data in Bytes*/
 .fd_enable = false,               /*!< Enable or disable FD*/
 .fd_padding = 0U,                 /*!< Set a value for padding. It will be used when the data length code (DLC)
                                   specifies a bigger payload size than data_length to fill the MB */
 .enable_brs = true,               /*!< Enable bit rate switch inside a CAN FD format frame*/
 .is_remote = false           /*!< Specifies if the frame is standard or remote */
};
PINS_DRV_SetMuxModeSel(PORTE, ePIN_24, PORT_MUX_ALT3); //CAN_H
PINS_DRV_SetMuxModeSel(PORTE, ePIN_25, PORT_MUX_ALT3);       //CAN_L�
      
FLEXCAN_DRV_Init(canNum, &canCom1_State, &canCom1_InitConfig0);
/* Configure Rx message buffer with index 1 to receive frames with ID 2 */
FLEXCAN_DRV_ConfigRxMb(canNum, RX_MAILBOX, &dataInfo, RX_MSG_ID);
INT_SYS_EnableIRQ(CAN2_ORed_0_15_MB_IRQn);

/* Configure Tx message buffer with index 1 to send frames with ID 1 */
FLEXCAN_DRV_ConfigTxMb(canNum, TX_MAILBOX, &dataInfo, msgId);

FLEXCAN_DRV_Send(canNum, TX_MAILBOX, &dataInfo, msgId, (uint8_t *)&sendData[i]);
hello, NXP

I 'm going to replace ".flexcanMode = FLEXCAN_LOOPBACK_MODE," with ".flexcanMode = FLEXCAN_NORMAL_MODE,",My program is not working property,in either case , my CAN module can not send data,why? whit is my problem?

My transceiver is TJA1044T.

0 件の賞賛
返信
1 解決策
2,457件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

the ESR1=0x40080 means module is synced to the bus and is idle.

So FLEXCAN_DRV_Send should work normally when called for first time for given MB. For next calling you should check MB status each time, using FLEXCAN_DRV_GetTransferStatus().

Do you use demo example? I have tested "flexcan_encrypted_s32k148" demo from latest RTM_SDK_3.0.0, modified it for CAN2 with pins you have. On the S32K1448EVB-Q176 I see CAN message on external loopback connection upon button is pressed.

BR, Petr

元の投稿で解決策を見る

0 件の賞賛
返信
6 返答(返信)
2,457件の閲覧回数
1351291614
Contributor I

你好 请问你的这个问题解决了吗,我也遇到了同样问题,请教下如何解决的

0 件の賞賛
返信
2,457件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

do you see any signal on CAN2 TX/RX pins? What is the value of ESR1 and ECR registers?

To simply check pins are properly configured, short TX and RX pins without transceiver connected. Then after you send a message you should see CAN frame on this external loop connection.

BR, Petr 

0 件の賞賛
返信
2,457件の閲覧回数
347996379
Contributor III

CAN2管脚初始化图片.png

Hi,

BR, Petr 

My pins are configured as 

PINS_DRV_SetMuxModeSel(PORTE, ePIN_24, PORT_MUX_ALT3); 
PINS_DRV_SetMuxModeSel(PORTE, ePIN_25, PORT_MUX_ALT3); 

This TX has a high level signal,5.5V.

  • and the value of ECR registers is zero,it means no error counter,the value of ESR1 registers is 0x40080,it means  the Tx error counter transitioned from less than 96 to greater than or equal to 96 and  CAN bus is now IDLE.

  • When the program runs to “ result = FLEXCAN_StartSendData(instance, mb_idx, tx_info, msg_id, mb_data, false)”,but the result is STATUS_BUSY,
  • I've spent a lot of time, but I can't figure it out. Can you help me?

/*FUNCTION**********************************************************************
*
* Function Name : FLEXCAN_DRV_StartSendData
* Description : Initiate (start) a transmit by beginning the process of
* sending data.
* This is not a public API as it is called from other driver functions.
*
*END**************************************************************************/
static status_t FLEXCAN_StartSendData(
uint8_t instance,
uint8_t mb_idx,
const flexcan_data_info_t *tx_info,
uint32_t msg_id,
const uint8_t *mb_data,
bool isBlocking
)
{
      DEV_ASSERT(instance < CAN_INSTANCE_COUNT);
      DEV_ASSERT(tx_info != NULL);

      status_t result;
      flexcan_msgbuff_code_status_t cs;
      flexcan_state_t * state = g_flexcanStatePtr[instance];
      CAN_Type * base = g_flexcanBase[instance];

      if (state->mbs[mb_idx].state != FLEXCAN_MB_IDLE)
      {
            return STATUS_BUSY;
      }
      state->mbs[mb_idx].state = FLEXCAN_MB_TX_BUSY;
      state->mbs[mb_idx].isBlocking = isBlocking;
      state->mbs[mb_idx].isRemote = tx_info->is_remote;

      cs.dataLen = tx_info->data_length;
      cs.msgIdType = tx_info->msg_id_type;

      #if FEATURE_CAN_HAS_FD
      cs.fd_enable = tx_info->fd_enable;
      cs.fd_padding = tx_info->fd_padding;
      cs.enable_brs = tx_info->enable_brs;
      #endif

      if (tx_info->is_remote)
      {
            cs.code = (uint32_t)FLEXCAN_TX_REMOTE;
      }
      else
      {
            cs.code = (uint32_t)FLEXCAN_TX_DATA;
      }
      result = FLEXCAN_SetTxMsgBuff(base, mb_idx, &cs, msg_id, mb_data);

      if (result != STATUS_SUCCESS)
      {
            state->mbs[mb_idx].state = FLEXCAN_MB_IDLE;
      }

      return result;
}

0 件の賞賛
返信
2,458件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

the ESR1=0x40080 means module is synced to the bus and is idle.

So FLEXCAN_DRV_Send should work normally when called for first time for given MB. For next calling you should check MB status each time, using FLEXCAN_DRV_GetTransferStatus().

Do you use demo example? I have tested "flexcan_encrypted_s32k148" demo from latest RTM_SDK_3.0.0, modified it for CAN2 with pins you have. On the S32K1448EVB-Q176 I see CAN message on external loopback connection upon button is pressed.

BR, Petr

0 件の賞賛
返信
2,457件の閲覧回数
347996379
Contributor III

yes,I have see the demo,but I could't find "Init_Config.h". So I can't find the defference between them.

0 件の賞賛
返信
2,457件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Not sure what is purpose of this *.h file, however it is not used in this demo example.

BR, Petr

0 件の賞賛
返信