LPC55S06 CAN TX issue

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

LPC55S06 CAN TX issue

1,477 次查看
gowthami_budideti
Contributor I

We are using LPC55S06 board, we're working with CAN, we are receiving the data from the CAN successfully but when we try CAN transmission it is not working. 

 

void can_transfer(uint16_t can_id)
{
memset(tx_data,'A',64);
txFrame.xtd  = kMCAN_FrameIDStandard;
txFrame.rtr  = kMCAN_FrameTypeData;
txFrame.fdf  = 0;
txFrame.brs  = 0;
txFrame.dlc  = 8U;
txFrame.id   = (can_id << STDID_OFFSET);
txFrame.data = tx_data;
txFrame.size = 8;
txXfer.frame = &txFrame;
txXfer.bufferIdx = 0;
 
MCAN_TransferSendBlocking(MAUTO_CAN,0, &txXfer);
 
}

after execution of this funciton code is waiting at   /* Wait until message sent out. */
while (0U == MCAN_IsTransmitOccurred(base, idx))   in MCAN_TransferSendBlocking fucntion so please suggest possibel issue with our code 

0 项奖励
回复
4 回复数

1,422 次查看
gowthami_budideti
Contributor I
 
MCAN_Init(MAUTO_CAN, &mcanConfig, MCAN_CLK_FREQ);
 
memoryConfig.baseAddr = (uint32_t)msgRam;
 
rxFifo0.address       = RX_FIFO0_OFS;
rxFifo0.elementSize   = 1U;
rxFifo0.watermark     = 0;
rxFifo0.opmode        = kMCAN_FifoBlocking;
rxFifo0.datafieldSize = kMCAN_8ByteDatafield;
#if (defined(USE_CANFD) && USE_CANFD)
rxFifo0.datafieldSize = BYTES_IN_MB;
#endif
memoryConfig.rxFifo0Cfg = &rxFifo0;
/* TX buffer config. */
txBuffer.address       = TX_BUFFER_OFS;
txBuffer.dedicatedSize = 1U;
txBuffer.fqSize        = 0;
txBuffer.datafieldSize = kMCAN_8ByteDatafield;
#if (defined(USE_CANFD) && USE_CANFD)
txBuffer.datafieldSize = BYTES_IN_MB;
#endif
memoryConfig.txBufferCfg = &txBuffer;
/* Set Message RAM config and clear memory to avoid BEU/BEC error. */
memset((void *)msgRam, 0, MSG_RAM_SIZE * sizeof(uint8_t));
if (kStatus_Success != MCAN_SetMessageRamConfig(MAUTO_CAN, &memoryConfig))
{
PRINTF("MCAN Message RAM configuration failed, please check parameters!\r\n");
return -1;
}
MCAN_EnableInterrupts(MAUTO_CAN, 0, CAN_IE_RF0NE_MASK);
EnableIRQ(CAN0_IRQ0_IRQn);

 

 

We're following the above configurations.

0 项奖励
回复

1,419 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Okay, I see that the TX buffer is initialized.

For the api function MCAN_TransferSendBlocking(MAUTO_CAN,0, &txXfer); it uses polling mode instead of interrupt mode, but the example architecture is based on interrupt mode.

Pls try to comment the MCAN_TransferCreateHandle(EXAMPLE_MCAN, &mcanHandle, mcan_callback, NULL); which enable and initialize the interrupt and have a try

Hope it is helpful

BR

XiangJun Rong

 

0 项奖励
回复

1,411 次查看
gowthami_budideti
Contributor I
void can_transfer(uint16_t can_id)
{
memset(tx_data,0,64);
txFrame.xtd = kMCAN_FrameIDStandard;
txFrame.rtr = kMCAN_FrameTypeData;
txFrame.fdf = 0;
txFrame.brs = 0;
txFrame.dlc = 8U;
txFrame.id = (can_id << STDID_OFFSET);
txFrame.data = tx_data;
txFrame.size = 8;
txXfer.frame = &txFrame;
txXfer.bufferIdx = 0;

MCAN_TransferSendBlocking(MAUTO_CAN, &mcanHandle, &txXfer);

while (!txComplete)
{
}
txComplete = false;
// MCAN_TransferSendBlocking(MAUTO_CAN, &mcanHandle, &txFrame);
// MCAN_TransferSendNonBlocking(MAUTO_CAN, &mcanHandle, &txXfer);
//
// status_t status = MCAN_WriteTxBuffer(MAUTO_CAN, 0, &txFrame);
// MCAN_TransmitAddRequest(MAUTO_CAN, 0);
// if(status == kStatus_Success)
// {
// UART_PRINT("Transmited CAN message!\r\n");
// }
// else
// {
// UART_PRINT("*Error: Failed to transmit CAN message*\r\n");
// }
}

MCAN_Init(MAUTO_CAN, &mcanConfig, MCAN_CLK_FREQ);

memoryConfig.baseAddr = (uint32_t)msgRam;

rxFifo0.address = RX_FIFO0_OFS;
rxFifo0.elementSize = 1U;
rxFifo0.watermark = 0;
rxFifo0.opmode = kMCAN_FifoBlocking;
rxFifo0.datafieldSize = kMCAN_8ByteDatafield;
#if (defined(USE_CANFD) && USE_CANFD)
rxFifo0.datafieldSize = BYTES_IN_MB;
#endif
memoryConfig.rxFifo0Cfg = &rxFifo0;
/* TX buffer config. */
txBuffer.address = TX_BUFFER_OFS;
txBuffer.dedicatedSize = 1U;
txBuffer.fqSize = 0;
txBuffer.datafieldSize = kMCAN_8ByteDatafield;
#if (defined(USE_CANFD) && USE_CANFD)
txBuffer.datafieldSize = BYTES_IN_MB;
#endif
memoryConfig.txBufferCfg = &txBuffer;
/* Set Message RAM config and clear memory to avoid BEU/BEC error. */
memset((void *)msgRam, 0, MSG_RAM_SIZE * sizeof(uint8_t));
if (kStatus_Success != MCAN_SetMessageRamConfig(MAUTO_CAN, &memoryConfig))
{
PRINTF("MCAN Message RAM configuration failed, please check parameters!\r\n");
return -1;
}
/*MCAN_EnableInterrupts(MAUTO_CAN, 0, CAN_IE_RF0NE_MASK);
EnableIRQ(CAN0_IRQ0_IRQn);*/
MCAN_TransferCreateHandle(MAUTO_CAN, &mcanHandle, mcan_callback, NULL);

still we are facing same issue
0 项奖励
回复

1,442 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Regarding your issue,  the api function MCAN_TransferSendBlocking(MAUTO_CAN,0, &txXfer); write TX buffer with the function status_t MCAN_WriteTxBuffer(CAN_Type *base, uint8_t idx, const mcan_tx_buffer_frame_t *pTxFrame); so before you call the MCAN_TransferSendBlocking(), you have to initialize the TX buffer with index 0.

You can use the following code to initialize TX buffer, Note that the TX_BUFFER_OFS is an accumulated address for TX buffer.

Pls refer to section 41.8.31 Tx buffer configuration register which specify the CAN buffer address in SRAM. Pls refer to the section 41.5.1 Message RAM configuration for the memory allocation.

 

/* TX buffer config. */
memset(&txBuffer, 0, sizeof(txBuffer));
txBuffer.address = TX_BUFFER_OFS;
txBuffer.dedicatedSize = 1U;
txBuffer.fqSize = 0;
txBuffer.datafieldSize = kMCAN_8ByteDatafield;
#if (defined(USE_CANFD) && USE_CANFD)
txBuffer.datafieldSize = BYTES_IN_MB;
#endif
MCAN_SetTxBufferConfig(EXAMPLE_MCAN, &txBuffer);

 

Hope it can help you

BR

XiangJun Rong

 

0 项奖励
回复