This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
我 正在研究需要修改 CAN 性能评测演示的概念验证。 主域和 MCU 域需要配置为 直接使用 CAN 端口进行通信。 第一步是让演示在 外部回送模式下在 mcu1_0和 MCU2_1上工作。 但是 、我在 J721e EVM 上工作、仅使用通用处理器板和 SOM、不使用 GESI 扩展板。
由于 MCU 域中只有两个 CAN 端口、因此可以在 mcu1_0上运行演示。 MCU MCAN0和 MCU MCAN1均通过 J31和 J30上的接头进行暴露。 但是、主域 MCU2_1上的演示配置为使用 MCAN4和 MCAN9。 这些接头仅可通过 GESI 扩展板进行访问。
我想修改 MCU2_1的演示以使用 MCAN0和 MCAN2、因为它们暴露在 J28和 J27接头处的通用处理器板上。 我对 CAN_Cfg 进行了必要的添加、但在 CANApp_Startup 中遇到了困难。 基于 TRM、以下应该是正确的 MCAN0和 MCAN2焊盘配置/多路复用:
/* MAIN MCAN 0 Tx PAD configuration */ regVal = 0x60000U; CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE + 0x1C20CU, regVal); /* MAIN MCAN 0 Rx PAD configuration */ regVal = 0x60000U; CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE + 0x1C208U, regVal); /* MAIN MCAN 2 Tx PAD configuration */ regVal = 0x60003U; CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE + 0x1C1F4U, regVal); /* MAIN MCAN 2 Rx PAD configuration */ regVal = 0x60003U; CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE + 0x1C1F0U, regVal);
但是、当我启用这些收发器时、我对正在发生的情况感到困惑。 我知道以下代码启用某些 GPIO 引脚的输出、但我无法理解原因:
/* Pin mux for CAN STB used in GESI board */ regVal = 0x20007U; CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE + 0x1C0F4U, regVal); /* Take MCAN transceiver out of STB mode for MCAN0 */ /* Set Pin direction to output */ regVal = CSL_REG32_RD(CSL_GPIO0_BASE + 0x38U); regVal &= (~(1U << 0x1BU)); CSL_REG32_WR(CSL_GPIO0_BASE + 0x38U, regVal); /* Drive Pin to Low */ Dio_WriteChannel(CAN_TRCV_MAIN_DOMAIN_4_9_11, STD_LOW); /* Read Pin level */ dioPinLevel[0] = Dio_ReadChannel(CAN_TRCV_MAIN_DOMAIN_4_9_11); /*Read back the pin levels to ensure transceiver is enabled*/ if (STD_LOW != dioPinLevel[0U]) { AppUtils_Printf(MSG_NORMAL, MSG_APP_NAME " Error in Enabling CAN Transceiver Main Domain Inst 4,9,11!!!\n"); } else { AppUtils_Printf(MSG_NORMAL, MSG_APP_NAME " Successfully Enabled CAN Transceiver Main Domain Inst 4,9,11!!!\n"); }
有人能否向正确的方向指出这些 GPIO 引脚如何与 MCAN 引脚交互? 文件的其余部分似乎是为了通过 I2C 与 GESI 板通信、这些引脚的用途是什么?
我现在正在尝试配置 mcu1_0的外部回送演示、以便从 MCU MCAN0发送并在主 MCAN0上接收。 我知道 GPIO 引脚用于使能和待机线路。
但是、即使现在我已经关闭了主 MCAN0的所有 MCU MCAN1接收代码、我的构建也不起作用。 它编译良好、看起来在电路板上运行、但不会发生传输。 我认为我的问题是配置邮箱。
CAN_Cfg.c:
/* HW Filter structure for all configsets */ CAN_CONFIG_DATA_SECTION_NON_CONST static Can_HwFilterType CanConfigSet_CanHardwareObject_3_CanHwFilter_0 = { 177U, /*CanHwFilterCode*/ 4294967295U, /*Filter Mask*/ }; CAN_CONFIG_DATA_SECTION_NON_CONST static Can_HwFilterType CanConfigSet_CanHardwareObject_4_CanHwFilter_0 = { 176U, /*CanHwFilterCode*/ 4294967295U, /*Filter Mask*/ }; CAN_CONFIG_DATA_SECTION_NON_CONST static Can_HwFilterType CanConfigSet_CanHardwareObject_5_CanHwFilter_0 = { 192U, /*CanHwFilterCode*/ 4294967295U, /*Filter Mask*/ }; CAN_CONFIG_DATA_SECTION_NON_CONST static Can_HwFilterType CanConfigSet_CanHardwareObject_6_CanHwFilter_0 = { 193U, /*CanHwFilterCode*/ 4294967295U, /*Filter Mask*/ }; CAN_CONFIG_DATA_SECTION_NON_CONST static Can_HwFilterType CanConfigSet_CanHardwareObject_8_CanHwFilter_0 = { 192U, /*CanHwFilterCode*/ 4294967295U, /*Filter Mask*/ }; /*List of the HW Filter structures */ CAN_CONFIG_DATA_SECTION_NON_CONST static Can_HwFilterType *CanConfigSet_CanHardwareObject_3_HwFilterConfigList[]= { &CanConfigSet_CanHardwareObject_3_CanHwFilter_0, }; CAN_CONFIG_DATA_SECTION_NON_CONST static Can_HwFilterType *CanConfigSet_CanHardwareObject_4_HwFilterConfigList[]= { &CanConfigSet_CanHardwareObject_4_CanHwFilter_0, }; CAN_CONFIG_DATA_SECTION_NON_CONST static Can_HwFilterType *CanConfigSet_CanHardwareObject_5_HwFilterConfigList[]= { &CanConfigSet_CanHardwareObject_5_CanHwFilter_0, }; CAN_CONFIG_DATA_SECTION_NON_CONST static Can_HwFilterType *CanConfigSet_CanHardwareObject_6_HwFilterConfigList[]= { &CanConfigSet_CanHardwareObject_6_CanHwFilter_0, }; CAN_CONFIG_DATA_SECTION_NON_CONST static Can_HwFilterType *CanConfigSet_CanHardwareObject_8_HwFilterConfigList[]= { &CanConfigSet_CanHardwareObject_8_CanHwFilter_0, }; /* All the Mailbox objects(MB's) will be defined here for all config sets */ CAN_CONFIG_DATA_SECTION_NON_CONST static Can_MailboxType CanConfigSet_CanHardwareObject_0 = { 0U, /* CanHandleType 0=Full, 1=Basic */ 1U, /* CanIdType 0=standard 1=Extended 2=Mixed*/ 0U, /* HwHandle i.e Mailbox - Hw object in the controller */ 12U, /* Length of the Mailbox */ CAN_MAILBOX_DIRECTION_TX, /* CanObjectType - Direction of Mailbox*/ &CanConfigSet_PC_CanController_0, /* Controller */ NULL_PTR, /* List of HW Filter structs */ 0U, /* Hw Filter Count */ 204U, /* Padding value for CAN FD message */ (boolean)FALSE, /* CanHardwareObjectUsesPolling */ }; CAN_CONFIG_DATA_SECTION_NON_CONST static Can_MailboxType CanConfigSet_CanHardwareObject_1 = { 0U, /* CanHandleType 0=Full, 1=Basic */ 1U, /* CanIdType 0=standard 1=Extended 2=Mixed*/ 0U, /* HwHandle i.e Mailbox - Hw object in the controller */ 12U, /* Length of the Mailbox */ CAN_MAILBOX_DIRECTION_TX, /* CanObjectType - Direction of Mailbox*/ &CanConfigSet_PC_CanController_0, /* Controller */ NULL_PTR, /* List of HW Filter structs */ 0U, /* Hw Filter Count */ 204U, /* Padding value for CAN FD message */ (boolean)FALSE, /* CanHardwareObjectUsesPolling */ }; CAN_CONFIG_DATA_SECTION_NON_CONST static Can_MailboxType CanConfigSet_CanHardwareObject_2 = { 0U, /* CanHandleType 0=Full, 1=Basic */ 1U, /* CanIdType 0=standard 1=Extended 2=Mixed*/ 0U, /* HwHandle i.e Mailbox - Hw object in the controller */ 12U, /* Length of the Mailbox */ CAN_MAILBOX_DIRECTION_TX, /* CanObjectType - Direction of Mailbox*/ &CanConfigSet_PC_CanController_2, /* Controller */ NULL_PTR, /* List of HW Filter structs */ 0U, /* Hw Filter Count */ 204U, /* Padding value for CAN FD message */ (boolean)FALSE, /* CanHardwareObjectUsesPolling */ }; CAN_CONFIG_DATA_SECTION_NON_CONST static Can_MailboxType CanConfigSet_CanHardwareObject_3 = { 0U, /* CanHandleType 0=Full, 1=Basic */ 0U, /* CanIdType 0=standard 1=Extended 2=Mixed*/ 0U, /* HwHandle i.e Mailbox - Hw object in the controller */ 12U, /* Length of the Mailbox */ CAN_MAILBOX_DIRECTION_RX, /* CanObjectType - Direction of Mailbox*/ &CanConfigSet_PC_CanController_0, /* Controller */ CanConfigSet_CanHardwareObject_3_HwFilterConfigList, /* List of HW Filter structs */ 1U, /* Hw Filter Count */ 0U, /* Padding value for CAN FD message */ (boolean)FALSE, /* CanHardwareObjectUsesPolling */ }; CAN_CONFIG_DATA_SECTION_NON_CONST static Can_MailboxType CanConfigSet_CanHardwareObject_4 = { 0U, /* CanHandleType 0=Full, 1=Basic */ 1U, /* CanIdType 0=standard 1=Extended 2=Mixed*/ 0U, /* HwHandle i.e Mailbox - Hw object in the controller */ 12U, /* Length of the Mailbox */ CAN_MAILBOX_DIRECTION_RX, /* CanObjectType - Direction of Mailbox*/ &CanConfigSet_PC_CanController_2, /* Controller */ CanConfigSet_CanHardwareObject_4_HwFilterConfigList, /* List of HW Filter structs */ 1U, /* Hw Filter Count */ 0U, /* Padding value for CAN FD message */ (boolean)FALSE, /* CanHardwareObjectUsesPolling */ }; CAN_CONFIG_DATA_SECTION_NON_CONST static Can_MailboxType CanConfigSet_CanHardwareObject_5 = { 0U, /* CanHandleType 0=Full, 1=Basic */ 1U, /* CanIdType 0=standard 1=Extended 2=Mixed*/ 1U, /* HwHandle i.e Mailbox - Hw object in the controller */ 12U, /* Length of the Mailbox */ CAN_MAILBOX_DIRECTION_RX, /* CanObjectType - Direction of Mailbox*/ &CanConfigSet_PC_CanController_0, /* Controller */ CanConfigSet_CanHardwareObject_5_HwFilterConfigList, /* List of HW Filter structs */ 1U, /* Hw Filter Count */ 0U, /* Padding value for CAN FD message */ (boolean)FALSE, /* CanHardwareObjectUsesPolling */ }; CAN_CONFIG_DATA_SECTION_NON_CONST static Can_MailboxType CanConfigSet_CanHardwareObject_6 = { 0U, /* CanHandleType 0=Full, 1=Basic */ 0U, /* CanIdType 0=standard 1=Extended 2=Mixed*/ 0U, /* HwHandle i.e Mailbox - Hw object in the controller */ 12U, /* Length of the Mailbox */ CAN_MAILBOX_DIRECTION_RX, /* CanObjectType - Direction of Mailbox*/ &CanConfigSet_PC_CanController_2, /* Controller */ CanConfigSet_CanHardwareObject_6_HwFilterConfigList, /* List of HW Filter structs */ 1U, /* Hw Filter Count */ 0U, /* Padding value for CAN FD message */ (boolean)FALSE, /* CanHardwareObjectUsesPolling */ }; CAN_CONFIG_DATA_SECTION_NON_CONST static Can_MailboxType CanConfigSet_CanHardwareObject_7 = { 0U, /* CanHandleType 0=Full, 1=Basic */ 0U, /* CanIdType 0=standard 1=Extended 2=Mixed*/ 0U, /* HwHandle i.e Mailbox - Hw object in the controller */ 1U, /* Length of the Mailbox */ CAN_MAILBOX_DIRECTION_TX, /* CanObjectType - Direction of Mailbox*/ &CanConfigSet_PC_CanController_2, /* Controller */ NULL_PTR, /* List of HW Filter structs */ 0U, /* Hw Filter Count */ 0U, /* Padding value for CAN FD message */ (boolean)FALSE, /* CanHardwareObjectUsesPolling */ }; CAN_CONFIG_DATA_SECTION_NON_CONST static Can_MailboxType CanConfigSet_CanHardwareObject_8 = { 0U, /* CanHandleType 0=Full, 1=Basic */ 0U, /* CanIdType 0=standard 1=Extended 2=Mixed*/ 0U, /* HwHandle i.e Mailbox - Hw object in the controller */ 1U, /* Length of the Mailbox */ CAN_MAILBOX_DIRECTION_RX, /* CanObjectType - Direction of Mailbox*/ &CanConfigSet_PC_CanController_2, /* Controller */ CanConfigSet_CanHardwareObject_8_HwFilterConfigList, /* List of HW Filter structs */ 1U, /* Hw Filter Count */ 0U, /* Padding value for CAN FD message */ (boolean)FALSE, /* CanHardwareObjectUsesPolling */ };
我交换了主 MCAN0的所有 MCU MCAN1标识符、但不能确信这是正确的。 我没有更改任何滤波器。 是否有人可以向我指出资源、以了解如何配置邮箱硬件对象? 或者将 mcu1_0外部环回演示转换为在 MCU MCAN0上传输和在主 MCAN0上接收的步骤?
最终目标是将 mcu1_0外部环回 CAN 性能评测演示转换为 使用主 MCAN0作为接收收发器、而不是 MCU MCAN1。 我已尝试执行 此相关帖子中的步骤:
1、将使用的实例的寄存器中断
CAN_CONFIG_DATA_SECTION_CONST const struct Can_ControllerStruct_PC CanConfigSet_PC_CanController_2 = { CanConf_CanController_CanController_2, /* Id as provided by GUI */ (boolean)TRUE, /* Contoller is used=1 or not_used=0*/ 0x2708000U, /* Can Controller Base Address */ CAN_TX_RX_PROCESSING_INTERRUPT, /* Can Rx Processing Type */ CAN_TX_RX_PROCESSING_INTERRUPT, /* Can Tx Processing Type */ (boolean)TRUE,/* BusOff TRUE = Interrupt FALSE = Polling */ CAN_CONTROLLER_INSTANCE_MCAN0, /* Controller Instance */ (boolean)TRUE, /* CAN FD Mode Enable */ }; // ... /** \brief MCAN0 Controller Instance ISR */ FUNC(void, CAN_CODE) Can_2_Int0ISR(void) { Can_IntISR_Function(CAN_CONTROLLER_INSTANCE_MCAN0, 0x2708000U); }
2.修改配置以添加控制器的配置和该控制器的邮箱(此时回路功能正常)
不确定如何配置 CAN_MailboxType 结构的字段 、但 此处的定义除外。
3.为 Tx 和 Rx 配置引脚多路复用。
/* MAIN MCAN 0 Tx PAD configuration */ regVal = 0x60000U; CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE + 0x1C20CU, regVal); /* MAIN MCAN 0 Rx PAD configuration */ regVal = 0x60000U; CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE + 0x1C208U, regVal);
4.配置收发器。
/* Configure SOC_PADCONFIG_143 set it to '1' to take MCAN transceiver out of STB mode */ I2C_Params i2cParams; I2C_Handle handle = NULL; uint8 dataToSlave[4]; /* * Configuring TCA6424 IO Exp 2 with addr 0x22 * This io expander is controlled by i2c0 * For Main MCAN2 P13 and P14 should be set to 0, This should route the MCAN2 STB line to transciver. * For Main MCAN0 P06 and P07 should be set to 1. */ /* I2c PinMux */ /* I2C0_SDL */ regVal = 0x40000U; CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE + 0x1C220U, regVal); /* I2C0_SDA */ regVal = 0x40000U; CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE + 0x1C224U, regVal); /* I2C initialization */ I2C_init(); I2C_Params_init(&i2cParams); i2cParams.transferMode = I2C_MODE_BLOCKING; i2cParams.bitRate = I2C_400kHz; i2cParams.transferCallbackFxn = NULL; handle = I2C_open(0U, &i2cParams); dataToSlave[0] = TCA6424_REG_CONFIG0 | TCA6424_CMD_AUTO_INC; dataToSlave[1] = 0x0U; SetupI2CTransfer(handle, 0x22, &dataToSlave[0], 2, NULL, 0); dataToSlave[0] = TCA6424_REG_INPUT0 | TCA6424_CMD_AUTO_INC; dataToSlave[1] = 0x0U; dataToSlave[2] = 0x0U; dataToSlave[3] = 0x0U; SetupI2CTransfer(handle, 0x22, &dataToSlave[0], 1, &dataToSlave[1], 3); /* Set P06 and P07 to 1. * Set P13 and P14 to 0. */ dataToSlave[0] = TCA6424_REG_OUTPUT0 | TCA6424_CMD_AUTO_INC; dataToSlave[1] |= 0xC0; dataToSlave[2] &= ~(0x18); SetupI2CTransfer(handle, 0x22, &dataToSlave[0], 1, &dataToSlave[1], 3);
我已经进行了多次修改和迭代,程序仍会在 Cani_TxConfirmationSemaphore 上等待释放。 我有跳线将 CAN_H、CAN_L 和 GND 从通用处理板上的 J30连接到 J27。
附加的是我已经接触过的源文件(profiling/CAN:main_rtos.c、CAN_profile.h、CAN_profile.c;profiling/co/SoC/j721e/mcu1_0:CanApp_Startup.h、 CanApp_Startup.c; mcal_config/CAN_Demo_Cfg/output/genered/soc/j721e/mcu1_0:include/CAN_Cfg.h、src/CAN_Cfg.c)。 我的大多数修改都通过预处理器 if 语句和 my_CAN_SIC_MOD 标志转义。
e2e.ti.com/.../can_5F00_profile_5F00_app_5F00_mcu1_5F00_0_5F00_modified.zip
Joseph
我假设您使用的是适用于 TDA4VM 的最新 SDK。
[引用 userid="534483" URL"~/support/processors-group/processors/f/processors-forum/1158618/tda4vm-q1-modify-j721e-can-profiling-demo-to-use-mcu-mcan0-and-main-mcan0-for-mcu1_0。]但是、主域的 MCU2_1上的演示配置为使用 MCAN4和 MCAN9。 这些接头只能通过 GESI 扩展板访问。[/QUERP]该演示还应为通用处理器板上的 MCAN0和 MCAN2配置收发器。
cusw/mcus_demos/profile/ca/soc /j721e/MCU2_1/canApp_Startup.c 文件中的 CANApp_EnableResetcums ()在通用处理器板上配置 MCAN0、MCAN2。 它还配置 MCAN4、MCAN5、 MCAN6、 MCAN7、MCAN9和 MCAN11 (在 GESI 卡上)、因为所有这些 MCAN 的收发器都由同一信号驱动。
[引用 userid="534483" URL"~/support/processors-group/processors/f/processors-forum/1158618/tda4vm-q1-modify-j721e-can-profiling-demo-to-use-mcu-mcan0-and-main-mcan0-for-mcu1_0 "]
我对 CAN_Cfg 进行了必要的添加、但在 CANApp_Startup 中遇到了困难。 基于 TRM、以下应该是正确的 MCAN0和 MCAN2焊盘配置/多路复用:
/* MAIN MCAN 0 Tx PAD configuration */ regVal = 0x60000U; CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE + 0x1C20CU, regVal); /* MAIN MCAN 0 Rx PAD configuration */ regVal = 0x60000U; CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE + 0x1C208U, regVal); /* MAIN MCAN 2 Tx PAD configuration */ regVal = 0x60003U; CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE + 0x1C1F4U, regVal); /* MAIN MCAN 2 Rx PAD configuration */ regVal = 0x60003U; CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE + 0x1C1F0U, regVal);
这已经存在于 mcusw/mcus_demos/profiling/cos/j721e/MCU2_1/CanApp_Startup.c 中的 CanApp_PlatformInit()函数中 这也会为 MCAN0和 MCAN2的 Tx 和 Rx 信号配置引脚多路复用。
[引用 userid="534483" URL"~/support/processors-group/processors/f/processors-forum/1158618/tda4vm-q1-modify-j721e-can-profiling-demo-to-use-mcu-mcan0-and-main-mcan0-for-mcu1_0 "]但是、当我启用这些收发器时、我对正在发生的情况感到困惑。 我知道以下代码启用某些 GPIO 引脚的输出、但我无法理解原因:
连接到 MCAN0和 MCAN2收发器的 EN 和 NSTB 引脚来自 I2C 控制的 GPIO 扩展器(TCA6424ARGJR)和2:1多路复用器(SN74CB3Q3257PWR)。 这段代码对它们进行了适当配置。
[引用 userid="534483" URL"~/support/processors-group/processors/f/processors-forum/1158618/tda4vm-q1-modify-j721e-can-profiling-demo-to-use-mcu-mcan0-and-main-mcan0-for-mcu1_0 ]是否有人可以向我指出正确的方向、以了解这些 GPIO 引脚如何与 MCAN 引脚交互? 文件的其余部分似乎是为了通过 I2C 与 GESI 板通信、这些引脚的用途是什么?[/quot]对于使用 TCAN1043收发器的 MCAN 正常运行、EN 应为高电平、STB 应为高电平(NSTB 应为低电平)。 这些信号可以由直接 SoC GPIO 驱动、也可以通过 电路板上的其他电路(在本例中为 GPIO 扩展器)进行路由。
此致
Karan
Joseph
[引用 userid="534483" URL"~/support/processors-group/processors/f/processors-forum/1158618/tda4vm-q1-modify-j721e-can-profiling-demo-to-use-mcu-mcan0-and-main-mcan0-for-mcu1_0/4369202 #4369202"]最终目标是将 mcu1_0外部环回 CAN 性能评测演示转换为 使用主 MCAN0作为接收收发器而不是 MCU MCAN1。是否能够从 MCU1_0发送并在 MCU MCAN1上接收?
如果是这样、那么您计划在 MCAN0上接收、那么您需要为 MCAN0注册中断、并在两者之间对中断路由器进行编程。 来自 MCAN0的中断不会直接路由到 MCU1_0。 您需要使用 TISCI_RM_IRQ_SET API 来实现此目的。
有关 示例,请参阅 mcusw/mcal_drv/mcal/examples/can/soc/j721e/mcu1_0/canApp_Startup.c 中的 CanApp_InterruptConfig ()。 另请参阅以下常见问题解答:
1、将使用的实例的寄存器中断
这段代码不会注册中断。 mcusw/mcus_demos/profiling/can/soc/j721e/MCU2_1/canApp_Startup.c 中的函数 CanApp_InterruptConfig ()将注册中断。
[引用 userid="534483" URL"~/support/processors-group/processors/f/processors-forum/1158618/tda4vm-q1-modify-j721e-can-profiling-demo-to-use-mcu-mcan0-and-main-mcan0-for-mcu1_0/4369202 #4369202"]2.修改配置以添加控制器的配置和该控制器的邮箱(此时回路功能正常)
不确定如何配置 CAN_MailboxType 结构的字段 、但 此处的定义除外。
[/报价]您应该为要接收的 MCAN 设置 Rx 邮箱、为计划发送的 MCAN 设置 Tx。 所有这些都必须位于该配置文件中:
mcus_demos/mcal_config/CAN_Demo_Cfg/输出/生成/soc/j721e/ /src/Can_Cfg.c
此致
Karan
此致
Karan
感谢您提供的信息响应、我忘记了实现中断路由。 我是否需要对 I2C0执行类似的操作? 我无法启用主 MCAN0 TCAN1043收发器。 它通过 I2C0总线上地址0x22处的 GPIO 扩展器进行连接。 根据我在数据表中可以收集的信息、以下代码应启用 TCA6424A 并将 P06和 P07设置为高电平:
/* * Configuring TCA6424 IO Exp 2 with addr 0x22 * This io expander is controlled by i2c0 * For Main MCAN0 P06 and P07 should be set to 1, This should route the MCAN0 EN and STB line to transciver. */ /* I2c PinMux */ /* I2C0_SDL */ regVal = 0x40000U; CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE + 0x1C220U, regVal); /* I2C0_SDA */ regVal = 0x40000U; CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE + 0x1C224U, regVal); /* I2C initialization */ I2C_init(); I2C_Params_init(&i2cParams); i2cParams.transferMode = I2C_MODE_BLOCKING; i2cParams.bitRate = I2C_400kHz; i2cParams.transferCallbackFxn = NULL; handle = I2C_open(0U, &i2cParams); dataToSlave[0] = TCA6424_REG_CONFIG0; dataToSlave[1] = 0x0U; SetupI2CTransfer(handle, 0x22, &dataToSlave[0], 2, NULL, 0); dataToSlave[0] = TCA6424_REG_INPUT0 | TCA6424_CMD_AUTO_INC; dataToSlave[1] = 0x0U; dataToSlave[2] = 0x0U; dataToSlave[3] = 0x0U; SetupI2CTransfer(handle, 0x22, &dataToSlave[0], 1, &dataToSlave[1], 3); /* Set P06 and P07 to 1. */ dataToSlave[0] = TCA6424_REG_OUTPUT0; dataToSlave[1] |= 0xC0; SetupI2CTransfer(handle, 0x22, &dataToSlave[0], 2, NULL, 0); dataToSlave[0] = TCA6424_REG_INPUT0; dataToSlave[1] = 0x0U; SetupI2CTransfer(handle, 0x22, &dataToSlave[0], 1, &dataToSlave[1], 1); if (0xC0U != (dataToSlave[1] & 0xC0U)) { AppUtils_Printf(MSG_NORMAL, MSG_APP_NAME " Error in Enabling CAN Transceiver MAIN MCAN0!!! TCA6424_REG_INPUT0: %x\n", dataToSlave[1]); } else { AppUtils_Printf(MSG_NORMAL, MSG_APP_NAME " Successfully Enabled CAN Transceiver MAIN MCAN0!!!\n"); }
具有以下辅助函数:
void SetupI2CTransfer(I2C_Handle handle, uint32 slaveAddr, uint8 *writeData, uint32 numWriteBytes, uint8 *readData, uint32 numReadBytes) { bool status; I2C_Transaction i2cTransaction; I2C_transactionInit(&i2cTransaction); i2cTransaction.slaveAddress = slaveAddr; i2cTransaction.writeBuf = (uint8 *)&writeData[0]; i2cTransaction.writeCount = numWriteBytes; i2cTransaction.readBuf = (uint8 *)&readData[0]; i2cTransaction.readCount = numReadBytes; status = I2C_transfer(handle, &i2cTransaction); if(FALSE == status) { AppUtils_Printf(MSG_NORMAL, "\n Data Transfer failed. \n"); } }
mcu1_0是否可以使用 I2C0?
Joseph
[引用 userid="534483" URL"~/support/processors-group/processors/f/processors-forum/1158618/tda4vm-q1-modify-j721e-can-profiling-demo-to-use-mcu-mcan0-and-main-mcan0-for-mcu1_0/4372405 #4372405">感谢您提供的信息响应、我忘记实现中断路由。 我是否需要对 I2C0执行类似的操作?[/QUERT]无需为 MCU2_1中的 I2C0使用配置中断路由器。
要设置收发器、请使用现有的 SDK 函数、我会看到 SDK 中的内容与您引用的内容之间存在一些差异。
CanApp_EnableResums ()的路径为 "mcusw/mcus_demos/profiling/can/soc/j721e/MCU2_1/CanApp_Startup.c"。
1.您能否确认如何确保 主 MCAN0 TCAN1043未启用? 是否探测 EN 和 STB 引脚?
2.您的引导流程是什么? 您如何加载此应用程序、以及在运行此应用程序时在其他内核上运行的是什么? 在使用 SD 引导和 SPL/u-boot 流引导至 A72上的 Linux 内核时、我在启用此收发器时遇到了问题。 这样做的原因是、我们尝试配置 IO 扩展器、Linux 在探测 SD 卡时也尝试配置该扩展器。 但是、如果您不是在 A72上引导 Linux、这不应该是问题。
此致
Karan
我还不明白此代码的作用:
/* Set P06 and P07 to 1. * Set P13 and P14 to 0. */ dataToSlave[0] = TCA6424_REG_OUTPUT0 | TCA6424_CMD_AUTO_INC; dataToSlave[1] |= 0xC0; dataToSlave[2] &= ~(0x18); SetupI2CTransfer(handle, 0x22, &dataToSlave[0], 1, &dataToSlave[1], 3);
第四个参数是否包含读取数据的缓冲区? 如果是这样、那么这种写入方式的写入方式会比寄存器地址多吗?
根据我对文档的理解、 要 根据 以下示例代码进行更改的 tissci_msg_rm_IRQ_set_req 结构的相关字段 为:src_id、src_index、dst_id 和 dst_host_IRQ。 您能否提供有关如何配置每个字段的更多信息? 下面是我尝试将中断从 MCU_MCAN0路由到 R5FSS0_Core1的代码:
(在 MCU2_1上从 MCAN0到 MCU_MCAN0运行外部回送)
void CanApp_InterruptConfig(void) { uint32 idx; OsalRegisterIntrParams_t intrPrms; OsalInterruptRetCode_e osalRetVal; HwiP_Handle hwiHandle; struct tisci_msg_rm_irq_set_req rmIrqReq; struct tisci_msg_rm_irq_set_resp rmIrqResp; Int32 retVal; const Can_ConfigType *Can_ConfigPtr; #if (STD_ON == CAN_VARIANT_PRE_COMPILE) Can_ConfigPtr = &CAN_INIT_CONFIG_PC; #else Can_ConfigPtr = &CanConfigSet; #endif for (idx = 0U; idx < Can_ConfigPtr->CanMaxControllerCount; idx++) { /* If the CAN instance is not in MAIN domain, the interrupt router will have to be configured */ if ((CAN_CONTROLLER_INSTANCE_MCU_MCAN0 == CanConfigSet_CanController_List_PC[idx]->CanControllerInst)) { CanApp_IntNumbers[idx] = APP_MCU_MCAN_0_INT0; // CSLR_R5FSS0_INTROUTER0_IN_MCU_MCAN0_MCANSS_MCAN_LVL_INT_0 (336U) rmIrqReq.valid_params = TISCI_MSG_VALUE_RM_DST_ID_VALID; rmIrqReq.valid_params |= TISCI_MSG_VALUE_RM_DST_HOST_IRQ_VALID; rmIrqReq.src_id = TISCI_DEV_MCU_MCAN0; rmIrqReq.global_event = 0U; /* Src Index 0 - mcanss_ext_ts_rollover_lvl_int, Src Index 1 - mcanss_mcan_lvl_int Line 0, Src Index 2 - mcanss_mcan_lvl_int Line 1 */ rmIrqReq.src_index = 1U; rmIrqReq.dst_id = TISCI_DEV_R5FSS0_CORE1; rmIrqReq.dst_host_irq = APP_MCU_MCAN_0_INT0; // CSLR_R5FSS0_INTROUTER0_IN_MCU_MCAN0_MCANSS_MCAN_LVL_INT_0 (336U) rmIrqReq.ia_id = 0U; rmIrqReq.vint = 0U; rmIrqReq.vint_status_bit_index = 0U; rmIrqReq.secondary_host = TISCI_MSG_VALUE_RM_UNUSED_SECONDARY_HOST; retVal = Sciclient_rmIrqSet( &rmIrqReq, &rmIrqResp, APP_SCICLIENT_TIMEOUT); if(CSL_PASS != retVal) { AppUtils_Printf(MSG_NORMAL, "CAN_APP: Error in SciClient Interrupt Params Configuration!!!\n"); } } /* Set the destination interrupt */ Osal_RegisterInterrupt_initParams(&intrPrms); intrPrms.corepacConfig.arg = (uintptr_t)CanApp_Isr[idx]; intrPrms.corepacConfig.isrRoutine = &CanApp_CanXIsr; intrPrms.corepacConfig.priority = 1U; intrPrms.corepacConfig.corepacEventNum = 0U; /* NOT USED ? */ intrPrms.corepacConfig.intVecNum = CanApp_IntNumbers[idx]; osalRetVal = Osal_RegisterInterrupt(&intrPrms, &hwiHandle); if(OSAL_INT_SUCCESS != osalRetVal) { AppUtils_Printf(MSG_NORMAL, MSG_APP_NAME " Error %d !!!\n"); break; } } return; }
根据 TRM 中的这些图、这似乎是正确的:
我认为、希望将中断路由到:
MCU_MCAN0_MCANSS_MCAN_LVL_INT_0 (R5FSS0_INTR0_IN_335)=> R5FSS0_INTR_IN_IN_IN[511:256](R5FSS0_INTROUTER0_OUTL_[255:0])
是这样吗? 它正在抛出"CAN_APP:SciClient 中断参数配置中的错误!!!" 误差。
Joseph
[引用 userid="534483" URL"~/support/processors-group/processors/f/processors-forum/1158618/tda4vm-q1-modify-j721e-can-profiling-demo-to-use-mcu-mcan0-and-main-mcan0-for-mcu1_0/4376921 #4376921"]您能否提供有关如何配置每个字段的更多信息?您可以在此处找到更多详细信息。
https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/rm/rm_irq.html#pub-rm-irq-route-set
[引用 userid="534483" URL"~/support/processors-group/processors/f/processors-forum/1158618/tda4vm-q1-modify-j721e-can-profiling-demo-to-use-mcu-mcan0-and-main-mcan0-for-mcu1_0/4376921 #4376921"]我认为、希望将中断路由到:
MCU_MCAN0_MCANSS_MCAN_LVL_INT_0 (R5FSS0_INTR0_IN_335)=> R5FSS0_INTR_IN_IN_IN[511:256](R5FSS0_INTROUTER0_OUTL_[255:0])
是这样吗?
[/报价]整个链将是:
MCU_MCAN0_MCANSS_MCAN_LVL_INT_0 (MCU MCAN0)=> R5FSS0_INTR0_IN_335 (中断路由器输入索引)=> R5FSS0_INTRTR0_OUT_[0:255] => MCIRQ_1 (rmIrqREQ.dst_host:511)
rmIrqReq.dst_host_IRQ 是 MCU2_1的中断编号。 这应该是系统中的可用 IRQ (尚未注册)、并且应该介于256:511之间、因为这些 IRQ 是连接到中断路由器的 IRQ。
我看到您将 rmIrqReq.dst_host_IRQ 编程为336、作为中断路由器的输入、 rmIrqReq.dst_host_IRQ 不是路由器的输入、而是核心的输入 IRQ。 您能否在 256:511之间为 rmIrqReq.dst_host_IRQ 尝试不同的数字、请确保这是系统中的空闲 IRQ。
此致
Karan