Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

TRAVEO™ T2G Forum Discussions

juan_2023
Level 1
Level 1
First like given First question asked Welcome!

你好,我在同一路CAN上配置经典CAN时能正常发送数据 ,但是按规格书配置为CANFD时,未能发送成功,想请问我以下配置是否正确。

cy_stc_canfd_config_t canCfg =
{
.txCallback = NULL, // Unused.
.rxCallback = CAN_RxMsgCallback,
.rxFifoWithTopCallback = NULL, //CAN_RxFifoWithTopCallback,
.statusCallback = NULL, // Un-supported now
.errorCallback = NULL, // Un-supported now

.canFDMode = true, // Use CANFD mode

#if (CY_USE_PSVP == 1)
// 24 MHz
.bitrate = // Nominal bit rate settings (sampling point = 75%)
{
.prescaler = 6u - 1u, // cclk/6, When using 500bps, 1bit = 8tq
.timeSegment1 = 5u - 1u, // tseg1 = 5tq
.timeSegment2 = 2u - 1u, // tseg2 = 2tq
.syncJumpWidth = 2u - 1u, // sjw = 2tq
},
.fastBitrate = // Fast bit rate settings (sampling point = 75%)
{
.prescaler = 3u - 1u, // cclk/3, When using 1Mbps, 1bit = 8tq
.timeSegment1 = 5u - 1u, // tseg1 = 5tq,
.timeSegment2 = 2u - 1u, // tseg2 = 2tq
.syncJumpWidth = 2u - 1u, // sjw = 2tq
},
#else
// 40 MHz
.bitrate = // Nominal bit rate settings (sampling point = 75%)
{
.prescaler = 10u - 1u, // cclk/10, When using 500bps, 1bit = 8tq
.timeSegment1 = 5u - 1u, // tseg1 = 5tq
.timeSegment2 = 2u - 1u, // tseg2 = 2tq
.syncJumpWidth = 2u - 1u, // sjw = 2tq
},
.fastBitrate = // Fast bit rate settings (sampling point = 75%)
{
.prescaler = 5u - 1u, // cclk/5, When using 1Mbps, 1bit = 8tq
.timeSegment1 = 5u - 1u, // tseg1 = 5tq,
.timeSegment2 = 2u - 1u, // tseg2 = 2tq
.syncJumpWidth = 2u - 1u, // sjw = 2tq
},
#endif

.tdcConfig = // Transceiver delay compensation, unused.
{
.tdcEnabled = false,
.tdcOffset = 0,
.tdcFilterWindow= 0,
},
.sidFilterConfig = // Standard ID filter
{
.numberOfSIDFilters = sizeof(stdIdFilter) / sizeof(stdIdFilter[0]),
.sidFilter = stdIdFilter,
},
.extidFilterConfig = // Extended ID filter
{
.numberOfEXTIDFilters = sizeof(extIdFilter) / sizeof(extIdFilter[0]),
.extidFilter = extIdFilter,
.extIDANDMask = 0x1fffffff, // No pre filtering.
},
.globalFilterConfig = // Global filter
{
.nonMatchingFramesStandard = CY_CANFD_REJECT_NON_MATCHING, // Reject none match IDs
.nonMatchingFramesExtended = CY_CANFD_REJECT_NON_MATCHING, // Reject none match IDs
.rejectRemoteFramesStandard = true, // No remote frame
.rejectRemoteFramesExtended = true, // No remote frame
},
.rxBufferDataSize = CY_CANFD_BUFFER_DATA_SIZE_64,
.rxFifo1DataSize = CY_CANFD_BUFFER_DATA_SIZE_64,
.rxFifo0DataSize = CY_CANFD_BUFFER_DATA_SIZE_64,
.txBufferDataSize = CY_CANFD_BUFFER_DATA_SIZE_64,
.rxFifo0Config = // RX FIFO0, unused.
{
.mode = CY_CANFD_FIFO_MODE_BLOCKING,
.watermark = 10u,
.numberOfFifoElements = 8u,
.topPointerLogicEnabled = false,
},
.rxFifo1Config = // RX FIFO1, unused.
{
.mode = CY_CANFD_FIFO_MODE_BLOCKING,
.watermark = 10u,
.numberOfFifoElements = 8u,
.topPointerLogicEnabled = false, // true,
},
.noOfRxBuffers = 4u,
.noOfTxBuffers = 4u,
};

 

{
Cy_SysClk_PeriphAssignDivider(PCLK_CANFD0_CLOCK_CAN1, CY_SYSCLK_DIV_8_BIT, 0u);
#if (CY_USE_PSVP == 1)
Cy_SysClk_PeriphSetDivider(CY_SYSCLK_DIV_8_BIT, 0u, 0u); // 24 MHz
#else
Cy_SysClk_PeriphSetDivider(CY_SYSCLK_DIV_8_BIT, 0u, 1u); // 40 MHz
#endif
Cy_SysClk_PeriphEnableDivider(CY_SYSCLK_DIV_8_BIT, 0u);
}

Cy_CANFD_DeInit(CY_CANFD_TYPE);

can_port_init(chno);

{
/* Setup CANFD interrupt */
cy_stc_sysint_irq_t irq_cfg;
irq_cfg = (cy_stc_sysint_irq_t){
.sysIntsrc=CY_CANFD_IRQN, /* Use interrupt LINE0 */
.intIdx = CPUIntIdx1_IRQn,//
.isEnabled = true,
};
Cy_SysInt_InitIRQ(&irq_cfg);
Cy_SysInt_SetSystemIrqVector(irq_cfg.sysIntSrc, CanfdInterruptHandler);
NVIC_SetPriority(CPUIntIdx1_IRQn, 0);
NVIC_ClearPendingIRQ(CPUIntIdx1_IRQn);
NVIC_EnableIRQ(CPUIntIdx1_IRQn);
}
{
Cy_CANFD_Init(CY_CANFD_TYPE, &canCfg);
SetISOFormat(CY_CANFD_TYPE);
}

{

cy_stc_canfd_msg_t stcMsg;

stcMsg.canFDFormat = true;
stcMsg.idConfig.extended = false;
stcMsg.idConfig.identifier = 0x525;
stcMsg.dataConfig.dataLengthCode = 15;
stcMsg.dataConfig.data[0] = 0x70190523;
stcMsg.dataConfig.data[1] = 0x70190819;
stcMsg.dataConfig.data[2] = 0x33332222;
stcMsg.dataConfig.data[3] = 0x33332222;
stcMsg.dataConfig.data[4] = 0x55554444;
stcMsg.dataConfig.data[5] = 0x77776666;
stcMsg.dataConfig.data[6] = 0x99998888;
stcMsg.dataConfig.data[7] = 0xBBBBAAAA;
stcMsg.dataConfig.data[8] = 0xDDDDCCCC;
stcMsg.dataConfig.data[9] = 0xFFFFEEEE;
stcMsg.dataConfig.data[10] = 0x78563412;
stcMsg.dataConfig.data[11] = 0x00000000;
stcMsg.dataConfig.data[12] = 0x11111111;
stcMsg.dataConfig.data[13] = 0x22222222;
stcMsg.dataConfig.data[14] = 0x33333333;
stcMsg.dataConfig.data[15] = 0x44444444;
Cy_CANFD_UpdateAndTransmitMsgBuffer(CY_CANFD_TYPE, 0, &stcMsg);

}

}

其中 stcMsg.canFDFormat = true;如果 我配置为false就能用工具收到CAN消息,但是只有8个字节,但如果配置为true就什么都没收到了。

期待回复,谢谢

 

0 Likes
1 Reply
Janine
Moderator
Moderator
Moderator
50 sign-ins 5 solutions authored 25 replies posted

Dear customer,

您好,可以试试用我们SDL里canfd的example代码试试么?以及can工具配置上是否有改成canfd呢?

BR,

Janine

0 Likes