cancel
Showing results for 
Search instead for 
Did you mean: 

PWM on PB.10 and PB.11 with DMA and TIMER2(CH3 e CH4)

esiqueira
Associate II
Posted on June 28, 2012 at 19:38

How can I configure PWM on TIMER2 (CH3 and CH4)?

I would like to configure CH4 in other Channel of the DMA,

but looks that only run on Channel 2.

 /* Configuracoes DMA */

 DMA_DeInit(DMA1_Channel2);

 DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)(&TIM2->CCR3);       // Associa Periferico

 //DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)(&TIM2->CCR4);       // Associa Periferico

 DMA_InitStructure.DMA_MemoryBaseAddr = (u32)PWM_Buffer;     // Associa Memoria

 DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;

 DMA_InitStructure.DMA_BufferSize = PWM_ELEMENTS;

 DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;

 DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;

 DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;

 DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;

 DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;

 DMA_InitStructure.DMA_Priority = DMA_Priority_High;

 DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;

 DMA_Init(DMA1_Channel2, &DMA_InitStructure);

 

 /* Habilita Canal 2 - DMA1*/

 DMA_Cmd(DMA1_Channel2, ENABLE);

#dma-timer2-ch3-ch4-pb.10-pb.11
2 REPLIES 2
Posted on June 28, 2012 at 19:57

DMA1_Channel2 is driven by TIM2_UP, and only that channel.

A 32-bit transfer doesn't help as the two 16-bit registers you want to write are too far apart.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
esiqueira
Associate II
Posted on June 28, 2012 at 21:38

THANKS CLIVE1,