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.

6746芯片使用EDMA向SPI总线发数



您好,请教关于6746使用EDMA实现SPI传输的问题,目前我的需求是:定时1s钟向SPI发送10个字节的数据,用EDMA实现向SPI总线发数.

我现在的做法,初始化EDMA通道时,OPT寄存器设置为0x8113290,link地址设置为0xffff,目前测试情况是DMA和SPI初始化完成后,第一次DMA向SPI发数正确,能够正确进入DMA传输完成中断。1s定时中断到了,想要启动第二次Dma传输,如何启动,需要设置什么寄存器吗?谢谢!

  • xiaoan li 说:
    第一次DMA向SPI发数正确,能够正确进入DMA传输完成中断。

    是10个数,还是一个数完成中断啊?

    提供详细的DMA paraset配置参数。

  • 要求10个数传输完成后产生中断,

    OPT:         0x8113290

    destAddr:  SPIDAT1

    srcAddr: RAM区变量

    aCnt:     4

    bCnt:      10

    cCnt:     1

    srcBIdx:    4

    destBIdx:    0

    srcCIdx:    0

    destCIdx:    0

    bCntReload:  10

    谢谢

  • All DMA/QDMA PaRAM sets must also specify a link address value. For repetitive transfers such as
    ping-pong buffers, the link address value should point to another predefined PaRAM set. Alternatively, a
    nonrepetitive transfer should set the link address value to the null link value. The null link value is defined
    as FFFFh. See Section 18.2.3.7 for more details.
    NOTE: Any incoming events that are mapped to a null PaRAM set results in an error condition. The
    error condition should be cleared before the corresponding channel is used again. See
    Section 18.2.3.5.

    按上面描述,第一次完成后,link到了null参数表,而SPI接口是一直使能的,所以在发完第10个数后还是会向EDMA发送事件请求下一个数的,而这时DMA参数为null,从而产生error,所以在下次启动之前要清掉:

    18.2.3.3 Null PaRAM Set
    A null PaRAM set is defined as a PaRAM set where all count fields (ACNT, BCNT, and CCNT) are
    cleared to 0. If a PaRAM set associated with a channel is a NULL set, then when serviced by the
    EDMA3CC, the bit corresponding to the channel is set in the associated event missed register (EMR or
    QEMR). This bit remains set in the associated secondary event register (SER or QSER). This implies that
    any future events on the same channel are ignored by the EDMA3CC and you are required to clear the bit
    in SER or QSER for the channel. This is considered an error condition, since events are not expected on
    a channel that is configured as a null transfer. See Section 18.4.2.5.8 and Section 18.4.2.2.1 for more
    information on the SER and EMR registers, respectively.

  • 你好,我按照您说的做法,在定时需要发送SPI的数据时,做了清除的处理操作,具体实现代码是:

    EDMA3ClrMissEvt(SOC_EDMA30CC_0_REGS,EDMA3_CHA_SPI1_TX)

     EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_SPI1_TX, EDMA3_TRIG_MODE_EVENT);

    但是问题并没有解决.

    仿真测试过程中,我查看EMR和SER寄存器,SPI1 发送相应的通道位并未置位,所以感觉可能不是这里的问题.

    想请问,当link地址设置为0xfffff是,是否能实现我想要的定时发送SPI数据的功能?谢谢

     

  • 这里还要重新disable SPI再enable SPI, 或者SPI的第一个字要手动写一下。因为前面SPI在第11个字的时候已经发出了DMA事件请求,但DMA为null参数所以没有给SPI送数,SPI还一直在等,在收到数之前是不会发送的DMA请求的。

    所以虽然清除了DMA的EMR,只是让DMA可以响应新的事件请求,但SPI目前不会发新的事件。

  • 或者说在第二次DMA参数配置完后,手动触发ESR启动一次EDMA传输给SPI送一个数.

  • 第二次还需要配置DMA的什么参数?

  • 跟第一次一样的配啊,因为第一次最后link到null了,全清0了。

  • 意思是要重新申请通道,重新配置通道参数,重新设置EER等等?

  • 是同一个通道啊,还是SPI对应的通道啊,只是参数表要重新配置,EER你没disable过就不用配啊,细节自己想想就清楚了。

    如果你原来配置是正确的,配置后加一步ESR触发一下,看SPI能不能重新动起来。

  • SPI对应的EDMA通道还需要再重新申请一次吗?

  • 你这是纯软件的说法,申请通道无非是拿到这个通道对应的参数表的地址。