TI中文支持网
TI专业的中文技术问题搜集分享网站

cc3200 如何通过dma方式实现pwm duty更改

大家好,

我想通过dma的方式实现pwm duty的修改,可是根本无法输出pwm波形,并且进入不了TimerA3IntHandler中断处理函数,代码如下,请各位大侠帮忙分析一下,十分感激

static void
TimerA3IntHandler(void)
{
    unsigned long ulStatus;
    
    //
    // Clear all interrupts for Timer unit 0.
    //
    ulStatus = MAP_TimerIntStatus(TIMERA3_BASE, true);
    MAP_TimerIntClear(TIMERA3_BASE, ulStatus);
    
    MAP_TimerEnable(TIMERA3_BASE, TIMER_A);
}

      for(uint8_t i =0;i<255;i++)
          duty_cycle[i] = i*DUTYCYCLE_GRANULARITY;
  //
    // TIMERA3 (TIMER B) as YELLOW of RGB light. GPIO 10 –> PWM_6
    //
    SetupTimerPWMMode(TIMERA3_BASE, TIMER_A,  (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PWM), 1);

    UDMAInit();

    UDMAChannelSelect(UDMA_CH6_TIMERA3_A, NULL);
     //
    // Setup DMA transfer for PWM
    //
      MAP_TimerIntRegister(TIMERA3_BASE,TIMER_A,TimerA3IntHandler);
          MAP_TimerIntEnable(TIMERA3_BASE,TIMER_TIMA_MATCH);
    
      UDMASetupTransfer(UDMA_CH6_TIMERA3_A,UDMA_MODE_BASIC,255,UDMA_SIZE_16,UDMA_ARB_1,
                      (void *)duty_cycle,
                      UDMA_SRC_INC_16,
                      (void *)(TIMERA3_BASE+TIMER_O_TAMATCHR),
                      UDMA_DST_INC_NONE);
        MAP_uDMAChannelAttributeEnable(UDMA_CH6_TIMERA3_A,UDMA_ATTR_HIGH_PRIORITY);
    MAP_TimerDMAEventSet(TIMERA3_BASE,TIMER_DMA_MODEMATCH_A);
    MAP_uDMAChannelRequest(UDMA_CH6_TIMERA3_A);
}

Viki Shi:

请参考CC3200 TRM的9.3.2.4节,提供了一个PWM的例程: www.ti.com/lit/ug/swru367d/swru367d.pdf

jack bi:

回复 Viki Shi:

Hi viki shi,thanks for your reply.in my application i want tochange pwm duty cycle by DMA mode,i have already posted codehere.will you pleasekindly havea lookand figure out the problem. i really can't find out the matter. many thanks

jack bi:

dear all,

         in my project, i  want to change pwm duty cycle through  DMA mode ,i have following config for this ,but it doesn't  work. i can't find  why. so any people can give me more advices? here i post my code, thanks

static voidTimerA3IntHandler(void){    unsigned long ulStatus;        //    // Clear all interrupts for Timer unit 0.    //    ulStatus = MAP_TimerIntStatus(TIMERA3_BASE, true);    MAP_TimerIntClear(TIMERA3_BASE, ulStatus);        MAP_TimerEnable(TIMERA3_BASE, TIMER_A);}

      for(uint8_t i =0;i<255;i++)          duty_cycle[i] = i*DUTYCYCLE_GRANULARITY;  //    // TIMERA3 (TIMER B) as YELLOW of RGB light. GPIO 10 –> PWM_6    //    SetupTimerPWMMode(TIMERA3_BASE, TIMER_A,  (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PWM), 1);    UDMAInit();    UDMAChannelSelect(UDMA_CH6_TIMERA3_A, NULL);     //    // Setup DMA transfer for PWM    //      MAP_TimerIntRegister(TIMERA3_BASE,TIMER_A,TimerA3IntHandler);           MAP_TimerIntEnable(TIMERA3_BASE,TIMER_TIMA_MATCH);          UDMASetupTransfer(UDMA_CH6_TIMERA3_A,UDMA_MODE_BASIC,255,UDMA_SIZE_16,UDMA_ARB_1,                      (void *)duty_cycle,                      UDMA_SRC_INC_16,                      (void *)(TIMERA3_BASE+TIMER_O_TAMATCHR),                      UDMA_DST_INC_NONE);         MAP_uDMAChannelAttributeEnable(UDMA_CH6_TIMERA3_A,UDMA_ATTR_HIGH_PRIORITY);    MAP_TimerDMAEventSet(TIMERA3_BASE,TIMER_DMA_MODEMATCH_A);    MAP_uDMAChannelRequest(UDMA_CH6_TIMERA3_A);}

赞(0)
未经允许不得转载:TI中文支持网 » cc3200 如何通过dma方式实现pwm duty更改
分享到: 更多 (0)