cancel
Showing results for 
Search instead for 
Did you mean: 

PWM no signal on TIM2 Channel1 and TIM3 Channel 1

Dan_Ko
Visitor

I want to generate 6 PWMs using channel 1 of timers 1,8,2,3,4,5. All of them are set the same way except ARR, PSC and CCR1 registers. However, it turned out that timers 2 and 3 don't have PWM signal on their pins. The content of registers for those timers are the same (checked during debugging). I also tried to initialize timers by writing directly to registers, with no luck. MCU: STM32F103RCT6. Here is the the initialization for timer 3, for example:

	// ------------------------- PA6 settings ------------------------- //
	RCC->APB2ENR |= RCC_APB2ENR_IOPAEN;		// Port A clock (PA6 - TIM3_CH1)
	GPIOA->CRL |= GPIO_CRL_MODE6; 			// PA6 speed MAX
	GPIOA->CRL &= ~GPIO_CRL_CNF6_0;			// Alternate function Push-Pull
	GPIOA->CRL |= GPIO_CRL_CNF6_1;
	// ------------------------- TIM3 settings ------------------------- //
	RCC->APB1ENR |= RCC_APB1ENR_TIM3EN; 	// TIM3 clock
	TIM3->CCMR1 &= ~TIM_CCMR1_OC1M_0;	// PWM mode 1
	TIM3->CCMR1 |= TIM_CCMR1_OC1M_1;
	TIM3->CCMR1 |= TIM_CCMR1_OC1M_2;
	TIM3->CCMR1 |= TIM_CCMR1_OC1PE;	        // enable preload register
	TIM3->CR1 |= TIM_CR1_ARPE;		// enable auto-reload preload register
	TIM3->EGR |= TIM_EGR_UG;	        // generate an update
	TIM3->CCER &= ~TIM_CCER_CC1P;	        // polarity: active HIGH
	TIM3->CCER |= TIM_CCER_CC1E;		// Output signal enable
	TIM3->ARR = 11999; 			// period
	TIM3->CCR1 = 5999;			// pulse %
	TIM3->PSC = 1; 				// prescaler
	TIM3->CR1 |= TIM_CR1_CEN; 		// PWM on

 I tried another STM32F103RCT6, but behaviour is the same. Is that hardware issue inside the MCU? 

0 REPLIES 0