2016-06-30 12:57 PM
I plan to use the STM32F40x TIM1 CH1 (PA8) to produce a varying PWM signal. The base frequency is set, say 1 MHz. I need to use DMA to change the PWM duty cycle on every iteration. I know this can be done by aiming the DMA at the TIM1_CCR1 register, but the question is which DMA stream to use.
The STM32F4xx Reference Manual (R12, May 2016) Table 43 says that DMA2 Channel 6, Stream 1 and Stream3 are both associated with TIM1, but which is the right one for the CCR1 register?I know that you program the address of the TIM1 CCR1 register into the appropriate DMA control registers, but that the correct stream has to be used so that the TIM1 PWM generation mechanism knows to notify the right DMA channel/stream when it is ready for the next value. #dma #tim1 #stm32f42016-06-30 02:21 PM
So either would work, the Channel is an input mux to the Stream. The DMA Unit supports 8 unique streams (akin to channels on IBM PC architectures of yore, and textbook examples)
Purpose of having choices is that you can pick the mix of DMA to support all the peripherals you use. I'd lean to using the Update as a trigger, as it occurs once per period instead of potentially chasing the phase of the counter. TIM1_UP would be DMA2 Stream 5 Channel 6 You'd write to &TIM1->CCR1, it would be a Half-Word (16-bit)2016-06-30 02:24 PM
Example of 32-bit TIM5 CH1 on APB1(DMA1), in case this saves me recreating the wheel
[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32F4%20DMA%20and%20Varying%20Duty%20Cycle&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/AllItems.aspx¤tviews=53]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fcortex%5fmx%5fstm32%2fSTM32F4%20DMA%20and%20Varying%20Duty%20Cycle&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https%3A%2F%2Fmy%2Est%2Ecom%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex%5Fmx%5Fstm32%2FAllItems%2Easpx¤tviews=53