完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,我在同一路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就什么都没收到了。 期待回复,谢谢 |
|
相关推荐
1个回答
|
|
可以试试用我们SDL里canfd的example代码试试么?以及can工具配置上是否有改成canfd呢?
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
277 浏览 0 评论
【敏矽微ME32G070开发板免费体验】之原厂2812测试例程解析
368 浏览 0 评论
766 浏览 2 评论
《DNESP32S3使用指南-IDF版_V1.6》第二十六章 INFRARED_RECEPTION实验
592 浏览 0 评论
879 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
12034 浏览 31 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-25 23:33 , Processed in 0.552626 second(s), Total 75, Slave 58 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号