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.

[参考译文] TMS320F280039C:手动控制 SPISTE 引脚时出现问题

Guru**** 1831610 points
Other Parts Discussed in Thread: SYSCONFIG
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1422488/tms320f280039c-problem-in-manually-controlling-spiste-pin

器件型号:TMS320F280039C
主题中讨论的其他器件:SysConfig

工具与软件:

Im 使用了 spi_ex3_external_loopback 示例并对其进行了修改、使 Im 在 SPIB 上仅传输16字节的数据、并通过手动控制 SPISTE 引脚。 代码如下:

//
// Included Files
//
#include "driverlib.h"
#include "device.h"
#include "board.h"
#include "f28003x_device.h"


//
//Macros
//
static inline void GPIO_SPI_FLASH_CS_CLEAR(void){
    GpioDataRegs.GPACLEAR.bit.GPIO15 = 1;
}

static inline void GPIO_SPI_FLASH_CS_SET(void)
{
    GpioDataRegs.GPASET.bit.GPIO15 = 1;
}

//
//Prototype
//
uint16_t spi_transmit_byte(uint16_t data_tx);

//
// Main
//
void main(void)
{
    uint16_t i;

    uint16_t TxData_SPIB[] = {0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F};

    //
    // Initialize device clock and peripherals
    //
    Device_init();

    //
    // Disable pin locks and enable internal pullups.
    //
    Device_initGPIO();

    //
    // Initialize PIE and clear PIE registers. Disables CPU interrupts.
    //
    Interrupt_initModule();

    //
    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    //
    Interrupt_initVectorTable();

    //
    // Board initialization
    //
    Board_init();

    //
    // Loop forever. Suspend or place breakpoints to observe the buffers.
    //
//    for(i = 0; i < 16; i++)
//    {
//        spi_transmit_byte(TxData_SPIB[i]);
//    }
    spi_transmit_multi_byte(TxData_SPIB, 16);
    //
    // Loop forever
    //
    while(1);
}

uint16_t spi_transmit_byte(uint16_t data_tx)
{
    uint16_t ret_val = 0U;
    /* Shift the data to MSbyte as the 8bit setting discards the LSbyte and transmits only MSbyte
     * Assert the CS low
     * Transmit the data and dummy read
     * Drive the CS high
     */
    data_tx = data_tx << 8U;
    GPIO_SPI_FLASH_CS_CLEAR();
    SPI_writeDataNonBlocking(SPIB_BASE, data_tx);
    SPI_readDataNonBlocking(SPIB_BASE);
    GPIO_SPI_FLASH_CS_SET();
    return ret_val;
}

uint16_t spi_transmit_multi_byte(uint16_t *buffer_tx, uint16_t len)
{
    uint16_t i, data_tx;
    uint16_t ret_val = 0U;
    /* Shift each data to be sent to MSbyte as the 8bit setting discards the LSbyte and transmits only MSbyte
     * Assert the CS low
     * Transmit all the data while dummy reading at the same time
     * Drive the CS high
     */
    GPIO_SPI_FLASH_CS_CLEAR();
    for (i = 0; i < len; i++)
    {
        data_tx = buffer_tx[i] << 8U;
        SPI_writeDataNonBlocking(SPIB_BASE, data_tx);
        SPI_readDataNonBlocking(SPIB_BASE);
    }
    GPIO_SPI_FLASH_CS_SET();
    return ret_val;
}

SysConfig 如下所示:

  

以下是 Im 在逻辑分析仪上观察到的情况:

我的问题是 、将 GPIO 用作 SPISTE 引脚会发生什么情况? Im 希望引脚 在整个 for 循环中保持低电平有效、直到传输完成。 我在这里遗漏了什么?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    嗨、Harsha、

    我看到 SysConfig 数据宽度长度为8、SPI_TRANSMIT_MULTI_BYTE 为16位、这两者为什么不同?  SPI 是16位对齐的、因此您需要一次发送16位。

    此致、

    Aishwarya.

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Aishwarya:

    感谢您的答复。 我选择仅使用8位传输的原因是导致 Im 尝试使用 SPI 闪存 SST25VF020B、如果看一下命令代码、它们的长度通常为8位、因此我觉得操作这个代码比使用16位更容易。 我可以尝试将此值更改为16位、但不确定如果我为1字节的命令代码发送2个字节、 但是、这并没有解决 Im 当前面临的问题、即手动控制的芯片选择引脚随机变为高电平、而我在数据 TX 函数调用中明确放置了"清除"并设置了 GPIO"、这意味着当数据在总线上发送时 IO 不应切换、但逻辑分析仪清楚地显示 IO 之前会切换。

    我觉得问题可能是由于比特率的原因、所以将比特率增加到了25MHz、但我不得不解决这个问题、即在芯片选择引脚已切换后、数据出现在总线上;

    那么、我的问题是在使用 SPI_writeDataNonBlocking 函数时、从调用函数的位置到总线上的数据需要多长的时间。

    接下来、我尝试使用 SPI_writeDataBlockingNonFIFO 函数、但我发现在发送第一个字节后大约需要2usec 的时间来传输第二个字节、我们可以减少这种情况吗?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Harsha,

    所以我的问题是当使用 SPI_writeDataNonBlocking 函数时、从调用函数的点开始将数据 传输到总线上需要多长时间。
    [quoteuserid="486552" url="~/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1422488/tms320f280039c-problem-in-manually-controlling-spiste-pin/5456082 #5456082"]接下来、我尝试使用 SPI_NonDataBlock2bytes 函数、但在发送后、我们发现它需要第二个字节来传输数据?

     TMS320F28003x 实时微控制器数据表(修订版 C)中的此处提供了任何相关的时序。 如果需要修改此时间、可以将 GPIO 用作 CS 并手动控制。 使用 GPIO 作为 CS 而不是 SPISTE 引脚是否也有原因?  

    此致、

    Aishwarya.

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    我想,将优化选项从关闭增加到1使一些奇怪的问题,这是其中之一,为了抵消,我只是添加了系统延迟1us 之前设置 CS 空闲,这就是我能够解决这个问题。