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.

求助:C6747如何通过SPI读取ADS8354 转换后输出的48bit的数据? EDMA3+SPI+ADS8354

Other Parts Discussed in Thread: ADS8354

各位大侠:

            C6747 通过SPI接口跟ADS8354这款AD相连接。ADS8354这款AD芯片的输出数据格式是48bit的,而6747的SPIBUF以及SPIDATA都是16位的,

问题就来了。

问题1: 如何才能读取到ADS8354输出的48位的结果呢?

  下图所示为ADS8354的SPI时序图:

                  

        我现在的思路是把SPI的片选设置为普通GPIO,人为控制GPIO拉低够48个时钟,这中间读取三次数据。但是这样就有一个问题:

读三次,每两次读取就会有较大的时间间隔2us左右(SPI时钟设置为24MHz),不知道这个间隔是否会影响读取AD的采样结果?

问题2 :如何使用EDMA3来读取这个AD采样后的数据呢?大致理解是用EDMA3关联SPI接口,但是SPI接口每次的48bit数据需要人为控制spi的片选来实现,这种情况怎么使用EDMA3呢?

希望高手指点下经验!或者有高手做过用EDMA3+SPI+AD这方面的经验的,跪求指点

十分感谢

  • 参考一下C6748的starterware里的SPI EDMA例程。简单来说,通过CSHOLD可以控制CS。

    The chip select signal is held active at the end of a transfer until a control field with new data and
    control information is loaded into SPIDAT1. If the new chip select hold information equals the
    previous one, the active chip select signal is extended until the end of transfer with CSHOLD
    cleared.


    /* Assert the CSHOLD line corresponding to the SPI Flash. */
    CSHoldAssert();

    /* Enable SPI controller to generate DMA events */
    SPIIntEnable(SOC_SPI_1_REGS, SPI_DMA_REQUEST_ENA_INT);

    /* Wait until both the flags are set to 1 in the callback function. */
    while((0 == flagTx) || (0 == flagRx));

    flagTx = 0;
    flagRx = 0;

    /* Deassert the CSHOLD line corresponding to the SPI Flash. */
    CSHoldDeassert();

    static void CSHoldAssert(void)
    {
    SPIDat1Config(SOC_SPI_1_REGS, (SPI_CSHOLD | SPI_DATA_FORMAT0), 0x01);
    }


    /*
    ** This function deasserts the CSHOLD line.
    */

    static void CSHoldDeassert(void)
    {
    SPIDat1Config(SOC_SPI_1_REGS, SPI_DATA_FORMAT0, 0x01);
    }


    void SPIDat1Config(unsigned int baseAdd, unsigned int flag, unsigned char cs)
    {
    unsigned char *ptr = (unsigned char*)(baseAdd + SPI_SPIDAT1);
    unsigned char dcs;

    *(ptr+3) = (char)((flag >> 24) | (flag & (SPI_SPIDAT1_DFSEL >>
    SPI_SPIDAT1_DFSEL_SHIFT)));

    dcs = HWREG(baseAdd + SPI_SPIDEF ) & (SPI_SPIDEF_CSDEF);

    *(ptr+2) = cs ^ dcs;
    }

  • 谢谢您  Tony Tang   

    我按照您的思路试一下,有疑问再请教您

    十分感谢