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