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.

[参考译文] MSPM0L1306:计时器的通用发布者事件示例

Guru**** 2447700 points
Other Parts Discussed in Thread: SYSCONFIG

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1244321/mspm0l1306-generic-publisher-event-example-of-timer

器件型号:MSPM0L1306
主题中讨论的其他器件: SysConfig

您好!

我想在每个周期更改 PWM 的占空比。

我将尝试 在每个周期使用 DMA 向捕获/计数器寄存器写入占空比。

我使用 GEN_EVENT0作为 DMA 触发源。

但我的项目无法正常工作。

PWM 事件设置

2. DMA 设置

我附加了一个项目文件。

e2e.ti.com/.../PWM_5F00_DMA_5F00_TEST_5F00_LP_5F00_MSPM0L1306.zip

我能否获得一些有关 计时器通用发布者事件示例的示例?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    对于 DMA1、配置为将数据从缓冲器移动到 PWM 加载值、但为什么 要按如下方式将 DMA1目标地址配置到另一个缓冲器?

      DL_DMA_setDestAddr (DMA、DMA_CH1_CHAN_ID、(uint32_t)&gPwmReg [0]);

    我认为您应该将数据移动到 CC 寄存器。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Gary Gao、

    将 DMA 目标地址设置为缓冲器的原因是首先测试 DMA 触发源。 这不是问题。

    我猜问题的原因是 DMA 用户设置。

    DL_DMA_setSubscriberChanID 函数不会自动包含在 SysConfig 生成的文件中。

    我正在尝试实现下图。 并尝试使用 DMA 而不是 SW 写入 TIMx.LOAD = A。

    ST 已提供示例和参考、如下链接所示。

    https://community.st.com/t5/stm32-mcus/custom-signal-generation-using-pwm-and-dma/ta-p/49809

    下面是我简单针对 PWM 和 DMA 操作测试的代码。

    它似乎工作正常、但我不知道我是否设置正确。

    e2e.ti.com/.../7723.ti_5F00_msp_5F00_dl_5F00_config.ce2e.ti.com/.../4452.ti_5F00_msp_5F00_dl_5F00_config.h

    /*
     * 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 DMA_TRANSFER_SIZE_WORDS (16)
    
    const uint16_t gSrcData[DMA_TRANSFER_SIZE_WORDS] =
    {1000, 5000, 10000, 15000, 20000, 25000, 30000, 35000,
     40000, 45000, 49999, 40000, 30000, 20000, 10000, 2000};
    
    uint16_t gDstData;
    
    volatile bool gChannel0InterruptTaken = false;
    
    volatile uint32_t gUpdateCnt;
    
    
    int main(void)
    {
        SYSCFG_DL_init();
    
        gUpdateCnt = 0;
        DL_TimerG_startCounter(PWM_0_INST);
    
        /* Setup interrupts on device */
        DL_SYSCTL_disableSleepOnExit();
        NVIC_EnableIRQ(DMA_INT_IRQn);
    
        /* Configure DMA source, destination and size */
        DL_DMA_setSrcAddr(DMA, DMA_CH0_CHAN_ID, (uint32_t) &gSrcData[0]);
        DL_DMA_setDestAddr(DMA, DMA_CH0_CHAN_ID, (uint32_t)(&PWM_0_INST->COUNTERREGS.CC_01[0]));
        DL_DMA_setTransferSize(DMA, DMA_CH0_CHAN_ID, DMA_TRANSFER_SIZE_WORDS);
        DL_DMA_setSubscriberChanID(DMA, DL_DMA_SUBSCRIBER_INDEX_0, PWM_0_INST_PUB_0_CH);
        DL_DMA_enableChannel(DMA, DMA_CH0_CHAN_ID);
    
    
        gChannel0InterruptTaken = false;
        DL_DMA_startTransfer(DMA, DMA_CH0_CHAN_ID);
    
        /* Wait for transfer */
        while (gChannel0InterruptTaken == false) {
            __WFE();
        }
    
        /* Breakpoint to inspect verification result */
        __BKPT(0);
    
    
        while (1)
        {
            __WFI();
        }
    }
    
    void PWM_0_INST_IRQHandler(void)
    {
        switch (DL_TimerG_getPendingInterrupt(PWM_0_INST))
        {
            case DL_TIMERG_IIDX_CC0_DN:
                gUpdateCnt++;
                default:
                    break;
        }
    }
    
    void DMA_IRQHandler(void)
    {
        /* Example interrupt code -- just used to break the WFI in this example */
        switch (DL_DMA_getPendingInterrupt(DMA)) {
            case DMA_IIDX_STAT_DMACH0:
                gChannel0InterruptTaken = true;
                break;
            default:
                break;
        }
    }
    

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    使用 SysConfig 正确执行配置吗? 如果是这样、那么代码应该没有问题。