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.

tms570, SCI2 TX dma support

Other Parts Discussed in Thread: TMS570LS3137, HALCOGEN

Dear friends,

I want to use SCI2 TX and DMA. I searched both this forum and google. I tried everything which experts suggested. Also I downloaded an example code from this forum, even it did not work. (code is in the attachment) .

The steps I follwed are:

       _enable_IRQ();

	//loadDataPattern(D_SIZE1,&TX_DATA1[0]);
	//loadDataPattern(D_SIZE2,&TX_DATA2[0]);

	/* - initializing mibspi - enabling tg 0 */
	sciInit();

	/* - DMA Configuration */

	/* Enable DMA */
	dmaEnable();

    /* Enable Interrupt after reception of data */
    dmaEnableInterrupt(DMA_CH0, BTC);

	/* assigning dma request: channel-0 with request line - 1  - TX*/
    /* DMA Request 29 is for LIN ( SCI2) Transmit */
    /* Refer Data sheet - Default DMA Request Map section */
	dmaReqAssign(DMA_CH0,29);

	/* --------------------------- */
	/* First Transfer of 120 Words */
	/* --------------------------- */

    /* Reset the Flag */
    DMA_Comp_Flag = 0xAAAA5555;

	/* - Populate dma control packets structure */
    dmaConfigCtrlTxPacket((uint32)(&TX_DATA1),
			             (uint32)(&(scilinREG->TD)),
			              D_SIZE1);

	/* - setting dma control packets for transmit */
    dmaSetCtrlPacket(DMA_CH0,g_dmaCTRLPKT);

	/* Enable TX DMA */
	scilinREG->SETINT |= (1 << 16);

    /* - setting the dma channel to trigger on h/w request */
    dmaSetChEnable(DMA_CH0, DMA_HW);

    /* Wait for the DMA interrupt ISR to set the Flag */
    while(DMA_Comp_Flag != 0x5555AAAA);  //set in the DMA irq routine

	/* Disable TX DMA */
   scilinREG->CLEARINT = (1 < 16);

So, I need help :)

Levent

4572.SCI_DMA.rar
  • Note: I converted the project  given in the attachment to tms570 project(originally it is rm48..), I checked memory adresses (SCI, DMA, DMARAM).

    It enters debug mode, I can run the code, but dma does not work. It seems I can not trig dma but why?

  • Levent,

    In order to use DMA with SCI, you need to (1) set up SCI module so that DMA request is generated when the TX and/or RX flag is set, and (2) set up DMA so that transfer is triggered by SCI. I am attaching a code snip showing what is needed. Although it is not a complete CCS project, you should be able to see what needs to be set up.

    2251.sci_dma.zip

    Thanks and regards,

    Zhaohong

  • Dear Zhaohong,

    I've also found and tested the code you sent to me before, but I tested it again,

    Unfortunately this code does not function as expected, DMA still not triggered, only the first byte of data is send to the terminal, which is clearly caused by the code:

    lin_ptr->SCITD_UN.SCITD_ST.TD_UC = LIN1_TxData[0];    //manually send the first data

    my test project is in the attachment.

    3036.SCI_DMA.rar

    An interesting point is, when I call sciSend function, it sends all bytes in polling mode (in TX irq mode, if TX irq is enabled), after that, dma BTC irq is generated.

  • Levent,

    I took a look at your project on CCS5 and noticed that the address for the SCI transmit/receive registers used are not correct. The addresses are for little endian but you have a big endian device. At build settings, I saw a little endian runtime library is linked. In the SCI header file reg_SCI.h, I do not think that transmit and receive registers are defined correctly. They are 8 bit registers and addresses are different for 8 bit access between big endian and little endian.

    I need to talk to more people to figure out how to fix it.

    Thanks and regards,

    Zhaohong

  • Hi Zhaohong,

    I checked the build options, as I saw the included library is "rtsv7R4_T_be_v3D16_eabi.lib", which is Big Endian,

    In "General" page of project options, TMS570LS3137 is selected, Device endianess is selected as "be32", but in the same page, Runtime support library is "rtsv7R4_T_le_v3D16_eabi.lib", however, the project compiles well, and only DMA does not work, I can send and receive uart data successfully either in polling or irq mode.

    I'll change this le library with be library, and let you know about the test results.

    In reg_sci.h, the definitions:

    #define sciREG ((sciBASE_t *)0xFFF7E500U)

    #define scilinREG ((sciBASE_t *)0xFFF7E400U)

    addresses seem to be correct, according to TRM.

    thanks for catching the bug.

    Levent

     

  • Hi friends,

    any suggestions for SCI2 (LIN) - DMA problem?

  • Levent,

    Let me put more details on the address issue in your code.

    The SCI transmit data register is at the lowest byte of the register at the address of 0xFFF7E438. Since the device is big endian,  you need to write to 0xFFF7E43B when writing to this register in 8 bit mode. When you use the address of "scilinREG->TD" for the 8bit DMA transfer, DMA will write to 0xFFF7E438 and nothing would happen. Your CPU writes work because it is a 32 bit write.  How did you generate this header file?

    Thanks and regards,

    Zhaohong

  • you are absolutely right,

    changing the destination address worked very well.

    thank you very much

    Levent

  • Sorry, but this is a bigger issue.

    I mean manual changing the address is not really what you want us to do?

    The same problem comes with the RD register.

    Do you have any solution for this?


    Kind regards,

    C.W.

  • C.W,

    If you are using TI compiler, you do not need to change your source code for endiness with the attached header file.

    7762.lin.h

    Thanks and regards,

    Zhaohong

  • Okay, since we are using a RTOS with a preconfigured Halcogen script we would like to use halcogen.

    Is there a way to tell halcogen to use big endiness. I mean the compiler can handle this but the header files are wrongly defined, or compiler switches are missing.

    kind regards,

    C.W.

  • C.W.

    HalCoGen doesn't provide a DMA driver, so it's not like it's actually inconsistent with itself.   The header is correct, but it's not convenient for DMA.

    I would probably in this case create a macro that adapts the uint32 type's address that you get from the HalCoGen header to a correct byte address, since you're wanting to make your DMA transfers byte size elements.  You can do this conversion by xor'ing the address with 0x3.   You can give the macro some name so you'll remember why you're doing this.

    Alternatively you might try type casting the address of the UINT32 as an array of bytes and selecting the 4th byte as the one that contains the RD register.  

    I wouldn't suggest trying to mix the LIN header from the attachment w. your HalCoGen projects though.