主题中讨论的其他器件:SysConfig
工具与软件:
您好、TI 团队:
关于 MCSPI 配置、我们有一个使用案例:SPI4作为控制器来支持多个器件。
对于单控制器模式、我们没有看到添加多个器件的芯片选择引脚配置选项。
只有在模式运行中选择了多控制器时、才允许我们选择多芯片选择。

但是、一旦我们切换到多控制器模式、SPI 操作在器件 ID 读取选项中失败。
TI 能否帮助提供正确的 SysConfig 设置以支持 SPI4上的多个器件?
谢谢!
Hong
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.
工具与软件:
您好、TI 团队:
关于 MCSPI 配置、我们有一个使用案例:SPI4作为控制器来支持多个器件。
对于单控制器模式、我们没有看到添加多个器件的芯片选择引脚配置选项。
只有在模式运行中选择了多控制器时、才允许我们选择多芯片选择。

但是、一旦我们切换到多控制器模式、SPI 操作在器件 ID 读取选项中失败。
TI 能否帮助提供正确的 SysConfig 设置以支持 SPI4上的多个器件?
谢谢!
Hong
您好、Hong:
感谢您在过去几天内提出的问题和耐心等待。
因此、"Single controller"选项预计只会有一个外设连接到它、因此您只会看到一个 CS 选项。
而"多控制器"选项可用于连接多个外设、因此您会看到可以添加多个 CS 选项、例如 CS0、CS1、...、CSn。
现在、让我们通读一下数据表、其中说明了有关 SPI4的以下内容:

根据您的封装类型、我需要您在 SysConfig 窗口中选择正确的焊球引脚编号、如下所示:

在执行此步骤之后、您拥有针对 CS 线路的正确配置以及针对 SPI4的正确焊球编号。
现在、我们需要查看输出数据和输入数据。 如果您的配置如下所示:

这意味着您的 SPI4_D0将向外设发送数据、而 SPI4_D1将从外设接收数据。
以上内容已经完成了对 SysConfig 配置的基本理解。
在此手册中、我希望您可以浏览以下代码片段、以便从 MCU 和 SDK 的角度了解通信应该是如何进行的。
// to communicate with Peripheral sitting on CS0 write the following code MCSPI_Transaction_init(&spiTransaction); spiTransaction.channel = gConfigMcspi0ChCfg[0].chNum; spiTransaction.dataSize = your data size; // limited to 32 bits spiTransaction.csDisable = TRUE; // this makes sure to disable CS once the transfer has finished, hence have it as TRUE at first for sanity checking spiTransaction.count = some count value; spiTransaction.txBuf = your tx buffer; spiTransaction.rxBuf = your rx buffer; spiTransaction.args = NULL; transferOK = MCSPI_transfer(gMcspiHandle[CONFIG_MCSPI0], &spiTransaction); // to communicate with Peripheral sitting on CSn write the following code MCSPI_Transaction_init(&spiTransaction); spiTransaction.channel = gConfigMcspi0ChCfg[n].chNum;// notice the numbering changes here from 0 to n spiTransaction.dataSize = your data size; // limited to 32 bits spiTransaction.csDisable = TRUE; // this makes sure to disable CS once the transfer has finished, hence have it as TRUE at first for sanity checking spiTransaction.count = some count value; spiTransaction.txBuf = your tx buffer; spiTransaction.rxBuf = your rx buffer; spiTransaction.args = NULL; transferOK = MCSPI_transfer(gMcspiHandle[CONFIG_MCSPI0], &spiTransaction);
希望以上内容可以帮助您 继续。
期待您的答复。
此致、
Vaibhav
您好、Vaibhav、
我们再次尝试启用了多控制器选项、但无法读取该 SPI 通道上的任何内容。
将其更改为单个时、我们可以成功读取该 SPI 通道上的第一个器件。
这是我们的 MCSPI 设置。 我们将使用 CLK、DI、DO 和 CS 的所有推荐引脚
SPI0 -单路控制器
SPI1 -单路控制器
SPI2 -单个外设
SPI4 -多控制器(不起作用)、单控制器我们可以看到第1个外设。
Jeff
尊敬的 Hong/Jeff:
我看了看代码. 在代码中、如果我们将 SPI 模式配置为多控制器模式、则 CS 线路不受驱动器控制。
因此、用户需要在传输/接收 数据之前控制 CS 线路。
"multicontroller (多控制器)"的名称造成混淆。 这种方法称为单个控制器和多个外设连接。
在这种情况下,用户需要在传输/接收 数据之前控制 CS 线路,并且生成的代码和当前驱动程序不支持控制多个外设支持 。 请尝试这种方法看看这是否有效.
请查看控制器和多个外设的图像连接。

此致、
Anil。
谢谢 Anil、
以下 API 功能需要传入 CS 引脚。
我们是否仍然需要将 CS 引脚传递到这些调用中?
对于这些函数中的哪些、我们需要在调用前将 CS 置为有效?
MCSPI_setDataWidth
MCSPI_readChStatusReg
MCSPI_readRxDataReg
MCSPI_enableTxFIFO
MCSPI_enableRxFIFO
MCSPI_readChCtrlReg
MCSPI_writeChCtrlReg
MCSPI_readChConf
MCSPI_writeChConfReg
Jeff
Jeff、Hong、您好!
另一个问题、如果我们只启用了一个 CS、我们仍然可以使用 "多控制器" 模式吗? [报价]是的、即使启用了一个 cs、您仍然可以使用多控制器模式。 我在之前的答复中也提到了这一点。 请在下面找到它。
然而"多控制器"选项可用于连接多个外设因此您将看到可添加多个 CS 选项、例如 CS0、CS1、...、CSn。Jeff、我看到您已将 SPI4配置为作为多个外设的主器件。
您能否在为 SPI4定义 mcspi 事务参数的位置共享您的代码?
我必须通篇讨论、然后再作进一步评论。
[报价 userid="558363" url="~/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1403248/am2432-question-regarding-multi_controller-setting-in-sysconfig-for-spi/5412247 #5412247"]MCSPI_setDataWidth
MCSPI_readChStatusReg
MCSPI_readRxDataReg
MCSPI_enableTxFIFO
MCSPI_enableRxFIFO
MCSPI_readChCtrlReg
MCSPI_writeChCtrlReg
MCSPI_readChConf
MCSPI_writeChConfReg[/QUOT]此外、您不需要为这些 API 调用显式指定、因为设置正确的事务参数可以为您执行该操作。
期待您的代码。
此致、
Vaibhav
[/quote]
您好、Hong:
是的、可以在 EVM 上进行测试。
我相信它将在很大程度上帮助你。
此致、
Vaibhav
Jeff、您好!
感谢您的耐心。
如果我们采用单控制器模式、则可以与芯片通话。 如果我们将其置于多模式、甚至不定义任何其他信道(因此仅定义第一个信道)、我们就无法再与它交谈。
我理解你在这里试图传达的信息。 这意味着每当将模式设置为多通道模式时、即使使用单个通道、驱动器也似乎无法按预期工作。
在继续之前、我想您肯定已经浏览过: C:\ti\mcu_plus_sdk_am243x_10_00_00_20\examples\drivers\mcspi\mcspi_loopback_multi_instances_multi_channels_lld。 我知道这是一个环回示例、但我想知道您是否通读过它。
我还注意到、在很多地方都没有提到或检查驱动器中的 chMode "MCSPI_CH_MODE_MULTI"、不管是对于 MCSPI 操作的中断/轮询模式。 我已经向开发团队询问了此问题的状态。
如果在明天的会议之前收到开发团队的反馈、我会将最新消息发布在这里。
此致、
Vaibhav
Jeff、您好!
我正在执行代码删除操作、以测试 SPI 驱动程序的功能。
我希望您删除应用中的多个测试、然后使用以下给定代码测试 SPI。
采用 MCU PLUS SDK 中的一个简单空 R5F Nortos 项目、并替换 main.c 文件中的以下内容。
/*
* Copyright (C) 2018-2021 Texas Instruments Incorporated
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdlib.h>
#include "ti_drivers_config.h"
#include "ti_board_config.h"
void oracle_spi_test(void *args);
int main(void)
{
System_init();
Board_init();
oracle_spi_test(NULL);
Board_deinit();
System_deinit();
return 0;
}
且 empty.c 文件应替换为以下代码。
/*
* Copyright (C) 2021 Texas Instruments Incorporated
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* This example demonstrates the McSPI RX and TX operation configured
* in blocking, interrupt mode of operation.
*
* This example sends a known data in the TX mode of length APP_MCSPI_MSGSIZE
* and then receives the same in RX mode. Internal pad level loopback mode
* is enabled to receive data.
* To enable internal pad level loopback mode, D0 pin is configured to both
* TX Enable as well as RX input pin in the SYSCFG.
*
* When transfer is completed, TX and RX buffer data are compared.
* If data is matched, test result is passed otherwise failed.
*/
#include <kernel/dpl/DebugP.h>
#include "ti_drivers_config.h"
#include "ti_drivers_open_close.h"
#include "ti_board_open_close.h"
#define APP_MCSPI_MSGSIZE (1U)
uint32_t gMcspiTxBuffer[APP_MCSPI_MSGSIZE];
uint32_t gMcspiRxBuffer[APP_MCSPI_MSGSIZE];
void *oracle_spi_test(void *args)
{
uint32_t i, j;
int32_t transferOK;
MCSPI_Transaction spiTransaction;
Drivers_open();
Board_driversOpen();
DebugP_log("[MCSPI] Oracle SPI Test started ...\r\n");
/* Memfill buffers */
for(i = 0U; i < APP_MCSPI_MSGSIZE; i++)
{
gMcspiTxBuffer[i] = 0x9F; // initializing tx buffer by writing 0x9F(data to be sent to Peripheral)
gMcspiRxBuffer[i] = 0U; // setting rx buffer as empty to recieve the value 0xC2201C
}
/* Initiate transfer */
MCSPI_Transaction_init(&spiTransaction);
spiTransaction.channel = gConfigMcspi0ChCfg[0].chNum;
spiTransaction.dataSize = 32;
spiTransaction.csDisable = TRUE;
spiTransaction.count = 1;
spiTransaction.txBuf = (void *)gMcspiTxBuffer;
spiTransaction.rxBuf = (void *)gMcspiRxBuffer;
spiTransaction.args = NULL;
transferOK = MCSPI_transfer(gMcspiHandle[CONFIG_MCSPI0], &spiTransaction);
if((SystemP_SUCCESS != transferOK) ||
(MCSPI_TRANSFER_COMPLETED != spiTransaction.status))
{
DebugP_assert(FALSE); /* MCSPI transfer failed!! */
}
else
{
/* Check if the data received is: 0xC2201C */
DebugP_log("Data in rx buffer is: %d\r\n", gMcspiRxBuffer[0]);
}
Board_driversClose();
Drivers_close();
return NULL;
}
确保添加 SysConfig SPI4实例(多控制器)、并且 CS0线路应连接到外设、在接收到9F 时将返回0xC2201C。
请告知我是需要构建失败还是一般性的进一步帮助。
此致、
Vaibhav