uchechukwu david
uchechukwu david

Reputation: 11

simultaneous use of stm32f103 timer channels

Is it possible to output different pwm signals on all the 4 capture/compare channels of an stm microcontroller, considering that there is only one event output register (AFIO->EVCR) which can only be configured for one port. How i use the different channels of a timer simultaneously ?

Upvotes: 0

Views: 1845

Answers (1)

Jeroen3
Jeroen3

Reputation: 935

The EVCR register is for EVENTOUT, to generate a pulse on an SEV instruction. That is feature of the cortex, not a timer.

To utilize timer PWM generation, use the TIMx CHx(N) channels.

Example of timer configuration:

  TIMx->CCMR1 = TIM_CCMR1_OC1PE           // Preload CCR (buffered)
              | (7<<TIM_CCMR1_OC1M_Pos);  // PWM mode 2, active while TIMx_CNT < TIMx_CCR1
  TIMx->CCER = TIM_CCER_CC1E;             // Enable output ch1
  TIMx->PSC = 3-1;                        // Prescaler (72 Mhz)
  TIMx->ARR = 48000-1;                    // Reload must be >0 to operate timer in INC mode
  TIMx->CNT = TIMx->ARR;                  // Immediate trigger
  TIMx->CCR1 = TIMx->ARR/2;               // 50%

Upvotes: 1

Related Questions