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.

IAR-KICKSTART: MSPM0G3507 UART TX + DMA Problem

Part Number: IAR-KICKSTART
Other Parts Discussed in Thread: MSPM0G3507, SYSCONFIG

Tool/software:

Hi IAR Team,

My customer is using MSPM0G3507 launchpad and they tried to send 9byte UART packet using DMA.

when they run this function only, it worked well but when they added timer interrupt, they saw there was missing bytes.(1~2 bytes)

it is not always happens but 3~4 times a seconds. optimization level does not matter.

when they use UART0, UART1, UART2 peripherals, the issue happens, and when they used UART3, it does not happens.

when the same code built by CCS, missing byte never happens.

IAR version info : 9.40.2.67587, Shared components :9.2.4.11209, sysconfig : 1.12.1+3772

I attached the source code.(sysconfig and c file)

https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/166/empty.syscfg

/*
 * Copyright (c) 2021, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "ti_msp_dl_config.h"

#define SET     (1)
#define CLEAR   (0)

#define COMM_BUF_SIZE (260U)

#define MS_FACTOR 80000
#define US_FACTOR 80

volatile uint32_t gu32MsFlag;


typedef struct Modbus
{
    uint8_t u08Address;
    uint8_t u08Function;
    uint8_t u08Data[COMM_BUF_SIZE];
}sModbus_t;

sModbus_t sTxMB;

int main(void)
{
    SYSCFG_DL_init();

    __disable_irq();
    __enable_irq();

    NVIC_EnableIRQ(TIMER_MAIN_INST_INT_IRQN);
    NVIC_EnableIRQ(TIMER_MS_INST_INT_IRQN);
    NVIC_EnableIRQ(UART_COMM_INST_INT_IRQN);
    DL_Timer_startCounter(TIMER_MAIN_INST);

    static uint32_t u32Test = 219;

    while (1) {
        do
        {

        }
        while(gu32MsFlag == CLEAR);
        gu32MsFlag = CLEAR;

        sTxMB.u08Address = 1;
        sTxMB.u08Function = 1;
        sTxMB.u08Data[0] = 1;
        sTxMB.u08Data[1] = 1;
        sTxMB.u08Data[2] = 1;
        sTxMB.u08Data[3] = 1;
        sTxMB.u08Data[4] = 1;
        sTxMB.u08Data[5] = 1;
        sTxMB.u08Data[6] = 1;

        DL_GPIO_setPins(GPIO_RS485_SEL_PORT, GPIO_RS485_SEL_PIN);
        DL_DMA_disableChannel(DMA, DMA_COMM_RX_CHAN_ID);

        DL_DMA_setSrcAddr(DMA, DMA_COMM_TX_CHAN_ID, (uint32_t) &sTxMB.u08Address);
        DL_DMA_setDestAddr(DMA, DMA_COMM_TX_CHAN_ID, (uint32_t) (&UART_COMM_INST->TXDATA));
        DL_DMA_setTransferSize(DMA, DMA_COMM_TX_CHAN_ID, 9);
        DL_UART_clearInterruptStatus(UART_COMM_INST, DL_UART_IIDX_DMA_DONE_TX);
        DL_DMA_enableChannel(DMA, DMA_COMM_TX_CHAN_ID);


        DL_Timer_setLoadValue(TIMER_MAIN_INST, u32Test);
        u32Test++;

        if(u32Test >= 500)
        {
            u32Test = 159;
        }

    }
}

void TIMER_MS_INST_IRQHandler(void)
{
    switch(DL_Timer_getPendingInterrupt(TIMER_MS_INST))
    {
        case DL_TIMER_IIDX_ZERO:
            gu32MsFlag = SET;
            break;

        default:
            break;
    }
}

void TIMER_MAIN_INST_IRQHandler(void)
{
    switch(DL_Timer_getPendingInterrupt(TIMER_MAIN_INST))
    {
        case DL_TIMER_IIDX_LOAD:
            DL_GPIO_setPins(GPIO_EMIT_PORT, GPIO_EMIT_PULSE_PIN);
            DL_Common_delayCycles(6*US_FACTOR);
            DL_GPIO_clearPins(GPIO_EMIT_PORT, GPIO_EMIT_PULSE_PIN);
            break;

        default:
            break;
    }
}

void UART_COMM_INST_IRQHandler(void)
{
    switch (DL_UART_Main_getPendingInterrupt(UART_COMM_INST))
    {
    case DL_UART_MAIN_IIDX_BREAK_ERROR:
    case DL_UART_MAIN_IIDX_OVERRUN_ERROR:
    case DL_UART_MAIN_IIDX_FRAMING_ERROR:
    case DL_UART_MAIN_IIDX_NOISE_ERROR:
        break;

    case DL_UART_MAIN_IIDX_EOT_DONE:
        DL_GPIO_clearPins(GPIO_RS485_SEL_PORT, GPIO_RS485_SEL_PIN);
        break;

    }
}



Could you help here?

Regards,

Ted

  • Hi Ted,

    IAR version info : 9.40.2.67587, Shared components :9.2.4.11209, sysconfig : 1.12.1+3772

    Would you let customer try the CPU clock with 32MHz (SYSOSC) for another try? To see whether the issue insists in IAR.

    B.R.

    Sal

  • They changed clock from 80Mhz to 32MHz but same issue happens.

    Could you guide?

  • Hi Ted,

    Thanks for the update. Please also help double check with customer that whether all the clock is 32MHz, including timer and uart.

    By the way, what SDK version customer are using?

    Meanwhile, please double check the device silkscreen, in case it is pre-samples. [When using CCS with official SDK version, it will show whether it is pre-samples]

    I will do test based on your provided source code with IAR, while I only have 9.50 version. And will update my test result here. -> This might need next week update. I am out of office for next few days.

    B.R.

    Sal

  • Hi Sal,

    I asked them to bypass PLL to supply 32MHz to MCLK, then the problem has gone. Communication was done normally.

    they used MSPM0_SDK_2_00_00_03.

    Is there a soultion for this issue?

    Regards,

    Ted

  • Hi Ted,

    I will send you an email offline for further clarification. This is an bug we need update to ERRATA with DMA in next released version.

    I am on busniess travel now, expected to update before next Monday.

    B.R.

    Sal

**Attention** This is a public forum