2021-06-28 06:27 AM
I have been trying to start PWM on TIM1 with complementary channels and use DMA to start the PWM. The problem that I have is that only one of the channels will start when I run the program. DMA channel 2 is being used by TIM1_CH1 and I can't find any other channel specifically for TIM1_CH1N. Here is a snippet from main that I have written.
int main(void)
{
const uint32_t lookup[100] = {1200,1275,1350,1424,1498,1570,1641,1710,1777,1842,1905,1964,2021,2074,2124,2170,2212,2251,2285,2315,2340,2361,2378,2390,2397,2399,2397,2390,2378,2361,2340,2315,2285,2251,2212,2170,2124,2074,2021,1964,1905,1842,1777,1710,1641,1570,1498,1424,1350,1275,1200,1124,1049,975,901,829,758,689,622,557,494,435,378,325,275,229,187,148,114,84,59,38,21,9,2,0,2,9,21,38,59,84,114,148,187,229,275,325,378,435,494,557,622,689,758,829,901,975,1049,1124};
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_DMA_Init();
MX_TIM1_Init();
HAL_TIM_PWM_Start_DMA(&htim1, TIM_CHANNEL_1, (uint32_t*)lookup, 100);
HAL_TIMEx_PWMN_Start_DMA(&htim1, TIM_CHANNEL_1,(uint32_t*)lookup, 100);
while (1) {}
}
My question is the following: Does TIM1_CH1N need a separate DMA channel to be able to start and if so, how can I access that channel on CubeMX. Right now the only peripherals from TIM1 that can be accessed are TIM1_CH1, TIM1_UP and TIM1_CH4/TRIG/COM.
When I start the two channels separately the PWM signals work so I know that there are no major problems with initializations. It's just when I start the two timer channels together that one of them won't start.
Solved! Go to Solution.
2021-06-28 06:30 AM
They are the same channel, in a sense, with one being (usually) the compliment of the other. There is only one CCR1 register.
In other words, you cannot control them independently.
2021-06-28 06:30 AM
They are the same channel, in a sense, with one being (usually) the compliment of the other. There is only one CCR1 register.
In other words, you cannot control them independently.
2021-06-28 06:41 AM
Thanks for the answer! I just realized with your reply that I don't need TIM1_CH1N to be started via DMA, I just need to start it with HAL_TIMEx_PWMN_Start() and it will act as the complement to TIM1_CH1. It works fine now.
2021-06-28 06:46 AM
Oh, I missed that your intent was to have them be controlled with the same data. Yeah, just initializing the pin correctly will get the signal over to the other channel, no further DMA configuration necessary.
2021-06-28 06:57 AM
The comment still helped and I appreciate you for taking the time to comment.