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.

To Haixiao - TMS570LS3137 MIBSPI and DMA configuration issue

Haixiao,

I am using MIBSPI mode.  Both MIBSPI1 (Master) and MIBSPI3 (Slave) are configured to use TG0, and try to use DMA transfer their TG0 RX data to RAM.

See the attachment for the DMA and MIBSPI1 and MIBSPI3 initialization. (I am using IAR embedded workbench IDE)

7024.ZZZ_temp.c

I already tried below 3 tests for your information -

(1) Instead of MibSPI1 TG0 RX trigger (request to DMA channel-0), I tried using Software Trigger DMA channel-0. The DMA channel 0 works.

(2) use DMA "chain", after DMA channel-1 (SPI3), chained with DMA channel-0 (SPI1), the DMA channel 0 also works.

(3) Instead of MibSPI TG0 RX trigger, tried using its TX to trigger DMA channel-0, because TG0 transmit and receiving operation complete at same time.

It turned out both MibSPI1 and MibSPI3 DMA channels do not work.

 

Thank you,

Yanzhong

 

Sounds like the SPI DMA source is not setting correctly.

Can you publish the code for setting the SPI1 hardware trigger? Please make sure what you use is SPI compatible mode or MIBSPI, their dma conguration channel are different.

BTW, I am going to seperate your post to a seperate one.

Regards,

Haixiao

 

TMS570LS3137 MCU Experts,

Sorry, I am using this old thread because I do not find how to start a new thread.

My questions are about TMS570LS3137 DMA application. It's urgent for us, hope to get your quick reply.

1. Background:

I have Dual high speed ADC chip with SPI port. Its dual SPI outputs are connected to MCU MibSPI-1 and MibSPI-3.

SPI-1 is in Master Mode and SPI-3 in Slave Mode. SPI-1 generates the SPI_/CS and SPI_CLK to drive the ADC SPI port and SPI-3 port simultaneously.

In order to minimize the CPU operation latency, I used SPI multi-buffer (using external trigger) and DMA to read data so that the entire process is handled by "hardware".

2. My question

SPI-1 multi-buffer TG-0 was defined to have only Buffer-0. i.e. every external trigger, SPI-1 will transmit ONE dummy data, and receive ONE data to Buffer-0 RX. SPI-3 also uses its TG0 with Buffer-0 only. SPI-3 will receive ONE data to Buffer-0 RX at same time.

Both SPI-1 and SPI-3 multi-buffer work well (can see data received in TG0 RX).  Then I assigned DMA channel-0 and channel-1 for SPI-1 TG0 RX and SPI-3 TG0 RX respectively. The settings are pretty similar for both channels.

I can see SPI-3 has transferred the data from TG0 RX to the destination in RAM. However, the DMA channel for SPI-1 did not work. 

Why? any comments are welcome.

(I tried using different DMA channels, even swapped the channels of SPI-1 and SPI-3, it's the same results - the DMA for SPI-3 TG0 RX worked, but not work for SPI-1)

 

One more update -

I tried the Software trigger the DMA channel for SPI-1. It works.

This tells me the DMA channel configuration is correct. It's the SPI-1 TG0 RX did not trigger (hardware) / not send request / or not response the request.

But I need the Hardware trigger.

 

Thanks,

Yanzhong

 

  • Yanzhong,

    //(5) DMA Request Assignment (All 16 are set by system default)

    DMADREQASI0_bit.CH0ASI = 0x00;//Request Line 0 trigger Ch-0

    DMADREQASI0_bit.CH1ASI = 0x01;//Request Line 1 trigger Ch-1

    Something is wrong here.

    MIBSPI1 DMA requestion line          requestion num inside DMA

    0                                                        1

    1                                                        0

    MIBSPI3 DMA requestion line          requestion num inside DMA

    0                                                        15

    1                                                        14

     I highlighted the one used in your code. Now sounds to me, you should configure:

    DMADREQASI0_bit.CH0ASI = 0x01;//Request Line 0 trigger Ch-0, mibspi 1

    DMADREQASI0_bit.CH1ASI = 14;//Request Line 1 trigger Ch-1 , mibspi 3

    Regards,

    Haixiao

  • Haixiao,

    Thanks for the quick answer.

    Have a good weekend!

    Yanzhong

  • Haixiao,

    This is Huichun, Yanzhong's workmate. Yanzhong is off this week, my question is for the SPI configuration(one master, one slave), we can get the the ADC data acquisition of two channels simutanuously. Both two channels use DMA, so can the DMA supports two channels(SPI) simutanuously? or there is a little latency of one from the other due to shared peripheral bus if there is?  Thanks,

    huichun

     

  • Yes, there will be a little big latency since this chip only has one DMA master. But this latency is tiny. DMA is running at the HCLK frequency, e.g180MHz, it access the peripheral bus faster (same frequency as the CPU but less latency than the CPU) than the R4F CPU. Use the DMA if possible.

    Regards,

    Haixiao

  • Hi, Haixiao, It's me. It's not easy to find you in the world. Fortunately the internet is powerful.

    Happy birthday!

     

    Fengrong

    (fengrong.ji@clariant.com)

  • Haixiao,

    I did some tests for Huichun's concern about the DMA latency between the two SPI channels.

    You are right. The latency can be ignored. 

    But I do need your advice for configure the settings in a right way -

    I use IAR Embedded Workbench IDE.  Every time I started the debugger by loading the program into Flash and executing it, I got the correct two channel data without latency. ( I set the board to read 1000 sets of data. Both channels started to get data from the 2nd reading.)

    When I clicked the debugger "reset" button (it supposes the debugger generate a reset signal to MCU) and executed the program, the two channels cannot read the data simulatanuously. For example, one channel (SPI Master) started to get data from the 33rd reading, the other (SPI Slave) started to get data from the 26th reading (the data is associated to the 33rd at the 1st channel). The latency between the two channel readings can be repeated unless I change the trigger signal frequency (I use a continuous squaredwave signal to trigger MIBSPI TG). 

    This might be related to my initialization - I may need to clear all the related flags/status bits before start to enable MIBSPI and DMA.

    Hope to hear your analysis and the solution. (what need to be cleared?)

    Note that my system is using SPI-1 (Master, MibSPI mode) and SPI-3 (Slave MibSPI mode), and DMA. The initialization code was attached before.

     

    Thanks,

    Yanzhong 

     

  • What does 2nd /33rd reading mean?

    What is your concern?

    Thanks for your post. See, your post served as the facebook and helped my highschool classmate find me.

    Regards,

    Haixiao

  • Haixiao,

    It's always great finding an old friend. Congritulations! - You became popular so easy when you work as an expert in the forum :-)

     

    1) The 26th/33rd readings are the data pointer # in my data array that the two DMA channels transfer and store data in the RAM.

    For example, in the case of the code was loaded into flash and started 1st execution (it just has the system initializations and a non-operation forever "while" loop),    MIBSPI1 TG0 and MIBSPI3 TG0 were triggered by the external trigger pulses at GIOA-pin2. Then the MIBSPI data were taken by DMA and stored in data array AI_A[*] and AI_B[*] respectively. For each trigger event, one set of data (dual channel)  were read, transfered, and stored .

    The DMA was set as one element per frame, frame trigger.  The frame count is 1000. i.e. the data array is from AI_A[0] to AI_A[999].

    AI_A[0] = 0x0000   AI_B[0]=0x0000   - both channels missed the first trigger data, it's ok.

    AI_A[1] = 0x055E   AI_B[1]=0x0560  - from the 2nd trigger, both channels got the same data  (both ADCs have the same Analog Input signal)

    AI_A[2] = 0x052A   AI_B[2]=0x052C

    AI_A[3] = 0x04F4   AI_B[3]=0x04F6

    :

    :

    AI_A[999] = 0x0360   AI_B[999]=0x0362 - the last set of the 1000 data

     

    2) based on above, when I clicked the "reset" botton in the IAR IDE debugger, the program pointer was reset to the start point, then I re-run the same code. 

    See the data array I got as below

    AI_A[0] = 0x0000   AI_B[0]=0x0000   - both channels missed the data

    AI_A[1] = 0x0000   AI_B[1]=0x0000  -

    :

    AI_A[25] = 0x0000   AI_B[25]=0x0000

    AI_A[26] = 0x0000   AI_B[26]=0x068C  - from the 26th trigger, channel-B (slave SPI) started to get data and saved

    AI_A[27] = 0x0000   AI_B[27]=0x06A1

    AI_A[28] = 0x0000   AI_B[28]=0x0679

    AI_A[29] = 0x0000   AI_B[29]=0x0654

    AI_A[30] = 0x0000   AI_B[30]=0x062B

    AI_A[31] = 0x0000   AI_B[31]=0x0601

    AI_A[32] = 0x0000   AI_B[32]=0x05D3

    AI_A[33] = 0x068B   AI_B[33]=0x05A3  - from the 33rd trigger, channel-A (master SPI) started to get data and stored. the AI_A[33] value matches AI_B[26]

    AI_A[34] = 0x069F   AI_B[34]=0x0571  - the AI_A[34] value matches AI_B[27]

    AI_A[35] = 0x0677   AI_B[35]=0x053D - the AI_A[35] value matches AI_B[28]

    AI_A[36] = 0x0652   AI_B[36]=0x0508 - the AI_A[36] value matches AI_B[29]

    Based on the data above, compare to the case of 1st code execution, there were two phenomena observed:

    (1) Both channels were delayed to get the 1st data.  the start point 26th/33rd can be repeated if remains the trigger signal frequency unchanged.

    (2) Channel-A started to get data ran a few trigger events late - (there still were same data value) 

    The data reading start point and the delay of trigger events # will change if the trigger signal frequency is changed.

     

    I am thinking this might be caused by the incomplete initialization.  After the 1st execution, some status were remained even if the MCU was reset, and they affected the following MibSPI or DMA operations.

    I'd like to get your advice before I start to try different settings.

    Yanzhong

     

     

     

     

  • Sounds timing problems to me. Do you mean:

    SPI1 CLK and CS drives both SPI3 and the AD chip?

    SPI1 SIMO - AD chip chan1 -SDI

    SP1 SOMI - AD chip chan1-SDO

    SPI3 SIMO - AD chip chan2 -SDO

    SP13SOMI - AD chip chan2-SDI

    If this is true, there are timing problems.

  • The AD chip does not have SDI signals. So, SPI1 SIMO and SPI3 SOMI were not connected.

    The SPI1 write a dummy to generate /CS and SPI clock to SPI3 and AD chip. The AD chip use these clocks to provide two channel data to SPI1 SIMO and SPI3 SOMI simultaneously.

    I did not see any timing issue.  and the "1st time" data reading (i.e. in debugger, after the flash programed), I can get the right data at both channels.

    Please explain what are the timing problems you concerned.

    Thanks,

    Yanzhong

     

  • Can you set the slave SPI3 as "trigger always"? Just want to make sure that SPI3 have enough time to prepare the data response to the SPI1 transfer.

    I don't understand why you get zeros in the DMA data. 2 possiblities:

    1) AD chip send zero value through SPI when the GIO trigger occurs (can you look at the data through a oscilliscope or logic analyzer?)

    2) SPI did not receive the data correctly. (Can you slow down the GIO trigger to catch such receive mismatch point and check the SPI RAM?)

    3) DMA did not handle the data correct.

    Regards,

    Haixiao

  • Haixiao,

    I think I've solved my problem.

    My initialization and function module enable sequences were not very good.

    The related module initialization sequence is important because my trigger signal speed is close to the limitation of the hardware capability.

    I've tried below initialization order. It seems work well.

    - Initialize MibSPI ports, but not enable the TG0s;

    - Initialize DMA, and - enable MibSPI TG0s, enable DMA;

    - Initialize GIOA module for external trigger signal to be enabled

    After this, the first a few data may be messed, then the two channel data stay being aligned.

     

    You can close the thread now. Thank you very much!

    Yanzhong