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.

AM3359 SPI RX

Other Parts Discussed in Thread: AM3359

Hello,


i am using the ICE-Board SPI0 as slave.

The SPI0 ist configured with EDMA. I have 3 Param Sets for RX. The first is the SPI0 RX Event paramset.17. Then i have a ping and pong paramset. One has ja wordcount of 6 the other one of 22 (to get 2 EDMA completion interrupts)

Now i´ve noticed, that the RXBUFFER is not being updated with new data. Only the first frame is one time correctly stored in the RXBUFFER, but then the new frames are not saved in this buffer. The SPI RX register changes the stored value.

So i think theres sth. with the EDMA ?

Can anyone give me a hint ?

Thank you.

  • Hi Daniel,

    There is StarterWare example of MCSPI(Master) with EDMA. The Slave device in use is Winbond W25Q64BV SPI compatible flash device. You could take this example as a reference for your design.

    You could find the example at AM335X_StarterWare_02_00_01_01\examples\evmAM335x\mcspi_edma\mcspiFlash_edma.c

    Regards,

    Jeethan

  • yes, i knew this example.
    But i think it´s more complexity in my case. I am now in the 3rd week to solve the EDMA problem.

    I have made some changes. I use only one Paramset for the 28Byte frame.

    My RXbuffer is everytime correctly updated.

    My TXBuffer is not correctly send out (first time it´s korrekt, then there is one Byte-error every TX)

    I get in theEDMA Completio ISR when the SPI TX Event occurs (EDMA Interrupt Pending Register / Interrupt Enable Register) The SPI RX Event is also enabled.


    My EDMA Completion ISR does the following:

    If the SPI TX event in EDMA Interrupt Pending Register is set then clear this event. (that in the next SPI cycle this register can be set)

    Then i change the TX Data frame, that in the next SPI cycle, other Data will be send.

    Then i wait still the SPI RX  event is set in EDMA IPR. After this i clear this event.

    The AM3359 as SPI slave get in 16kHz period the data with 8MBaud.

    Every time after the datatransfer is finish, the Edma ISR would be called (when the last 4bits get transmit/receive), this is the SPI TX EDMA Event. 2µs later the SPI RX EDMA Event occurs.

    The Problem at the SPI TX is, after the Paramset is done, it reloads a copy paramset which is given in the LINK.

    When this is done, the EDMA TX counts "1" (BCNT) down, and write the first TX Byte to the SPI TX Buffer (Shift Register) from the TXArray (old) before i can update this array.

    In the ISR i make an TXArray update, but EDMA already pushed one byte into TX SPI Buffer. ...

    This causes that 1 Byte error ...

    Where is the mistake in my program ? Have i take a look to the paramset, what i have to change there? I am in continous mode.
     

    I also can try a single shot mode, that the paramset is not automatically reloaded..

    In this case: How i must configure the param set?

    Maybe i must disable the EDMA completely, or i have to use other functions, that stop and start the transfer.

    As slave the TI gets the clock and hast to respond to it.

    Thank you.

  • Hi Daniel,

    I guess the issue you are seeing in your code is because a Tx event is getting generated by the SPI when the param set is not ready. You could resolve this by using a dummy paramset. Explanation is given in this link http://processors.wiki.ti.com/index.php/StarterWare_McSPI.

    Also are you getting any EDMA error interrupts?

    Regards,

    Jeethan

  • Hello,
    i have tried the EDMA to use with a dummyparamset. It does not worked, maybe i have to check this one more time. To eliminate the 1byte inthe SPI Tx register.

    In the last time i have checked a few variations of paramsets and now i have tried to change from event to manual trigger.

    Problem:

    when i am in the overall completion interrupt. Its the EDMA SPI RX event (the TX is a few µs earlier) i make a memcpy() of the rxBuffer to store the received data. After this, the EDMA has no more access to this memory section. I don´t know why the EDMA will be blocked to write newly RX data to the memory.

    What i want to reach is as follows:

    -rxData (28bytes) saves to memory
    -after 6bytes getting a first completion interrupt (the other bytes will be RX and TX in background )
    -in the completion interrupt i make calculations with the first received 6bytes
    -then i will change the last 5bytes (of the 28byte frame) of txData, (while EDMA works with the txBuffer)

    Can you give me a hint, in which way i have to programm the EDMA / Paramset ? (one 6byte one 22byte paramset?)

    Which trigger? Event or Manual? Maybe with manual i don´t have the memory access problem?

    Thank you.

  • Any ideas?

    My ParamSets:

    For SPI RX Event 17 Paramset 17:

    Opt = 0x80111000
    SRC = SPI RX0 ShiftRegister
    DST = rxBuffer
    Acnt=1
    Bcnt = 28
    Ccnt = 1
    DSTBidx = 1
    BCNTRLD= 28
    Link = 0x4880 (set 68)

    ParamSet 68 is a copy of Paramset 17 and with link on itself

    RX works, i see the data is updated everytime in my rxBuffer in memory. Still i do not copy/save the rxBuffer in another variable.

    For SPI TX Event 16 Paramset 16:

    Opt = 0x80110000
    SRC = txBuffer
    DST = SPI TX0 ShiftRegister
    Acnt=1
    Bcnt = 28
    Ccnt = 1
    SRCBidx = 1
    BCNTRLD= 28
    Link = 0x4880 (set 64)


    Paramset 64 Dummy Set

    • A B C cnt set to "0"

    With the dummy paramset my goal is, that after one frame ist transferd via SPI, the next byte which the SPI loads, should not be the first from the previous transferred frame.

    When the TX Dummy Paramset is loaded, i got an error in EMR, and in the ErrorHandlerInterrupt i clear this error. Then i disable the SPIDMA Event in SPI Register, set the Paramset 16 new (like at the begining configuration) and enable the SPIDMA Event in SPI Register.

    The first transfer looks good, after this, the first byte in TX would be changed, but not the other ones. And sometimes the SPI transmit wrong data.


    Next, i will try the ping-pong buffering

    If the paramsets are not configured correctly, please give me a hint. Thank you.

  • Problem solved.

    First i´ve took not the DUmmyparamset configration. I have ping pong buffering.

    • txPingBuffer and txPongBuffer
    • rxPingBuffer and rxPongBuffer

    I had the korrekt memory values for tx and rx, but i´ve seen wrong tx data !

    Wrong tx data, because the EDMA takes data from memory, but the new data is not copied from cache to memory.

    This issue helps to solve my problem:

    http://e2e.ti.com/support/embedded/starterware/f/790/t/301593.aspx?pi199177=1

    1. DATA_ALIGN() : aligned buffers 64byte
    2. CacheDataInvalidateBuff() before memcpy()

    Now the correct data is copied to memory.

    Best regards,

    Daniel