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.

TM4C1294KCPDT: Timer-uDMA-SSI synchronization problem

Part Number: TM4C1294KCPDT

Hello!

In my design I use timer and uDMA to continuousely generate sine waveform with SPI-based DAC. My sine frequency is 10kHz, and I use 32 samples per period to generate it, so sample period for DAC writes is 375 clock cycles.

The setup code is:

    uDMAChannelAttributeDisable(18, UDMA_ATTR_ALTSELECT | UDMA_ATTR_HIGH_PRIORITY |
                                UDMA_ATTR_REQMASK);
    uDMAChannelScatterGatherSet(18, 2, SSIDACTasks, true);
    memcpy(DMASave + 8, pui8ControlTable + (18 * 16), 16);
    uDMAChannelAttributeEnable(18, UDMA_ATTR_USEBURST | UDMA_ATTR_HIGH_PRIORITY);
    uDMAChannelEnable(18);

...

    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
    TimerConfigure(TIMER1_BASE, TIMER_CFG_SPLIT_PAIR / TIMER_CFG_A_PERIODIC);
    TimerLoadSet(TIMER1_BASE, TIMER_A, g_ui32SysClock / 320000);
    TimerDMAEventSet(TIMER1_BASE, TIMER_DMA_TIMEOUT_A);
    TimerEnable(TIMER1_BASE, TIMER_A);

The scatter-gather table:

tDMAControlTable SSIDACTasks[] =
{
 uDMATaskStructEntry(32, UDMA_SIZE_16, UDMA_SRC_INC_16, SinT, UDMA_DST_INC_NONE, SSI3_BASE + SSI_O_DR, UDMA_ARB_1, UDMA_MODE_PER_SCATTER_GATHER),
 uDMATaskStructEntry(4, UDMA_SIZE_32, UDMA_SRC_INC_32, DMASave + 8, UDMA_DST_INC_32, pui8ControlTable + (18 * 16), UDMA_ARB_1, UDMA_MODE_MEM_SCATTER_GATHER)
};

Then, I see in my scope clear ang good sine waveform. But I need to set up some tasks to occur at next sine period end. When I did it I noticed my tasks (including data aquisition) is not synchronous to sine period.

Then I set up another timer to toggle different pin with exact period of 375*32 clock cycles, which should be exactly synchronous to sine wave period:

    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER3);
    TimerConfigure(TIMER3_BASE, TIMER_CFG_PERIODIC | TIMER_CFG_A_ACT_TOGGLE);
    TimerLoadSet(TIMER3_BASE, TIMER_A, g_ui32SysClock / (320000 / 32));
    TimerSynchronize(TIMER3_BASE, TIMER_1A_SYNC);
    TimerEnable(TIMER3_BASE, TIMER_A);
    GPIOPinTypeTimer(GPIO_PORTA_BASE, GPIO_PIN_6);
    GPIOPinConfigure(GPIO_PA6_T3CCP0);

And I see on my scope that sine wave is not synchronous to timer output and the frequency generated by timer does not match doubled frequency of sine wave.

What is wrong?