cancel
Showing results for 
Search instead for 
Did you mean: 

Clearing the OCxREF signal on an external event

terence-b
Associate II
Posted on May 03, 2013 at 11:15

Hi

I'm having a problem with clearing the OC1, 2 and 3 references. I'm using the following code for configuring PE7 as the external trigger and for enabling the OCrefs clear:

  /* Configure PE7 as External Trigger Input for clearing OCrefs of Timer 1 */

  /* and enable OCref Clear for each channel */

  RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOE, ENABLE);

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;

  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;

  GPIO_Init(GPIOE, &GPIO_InitStructure);

  TIM_ETRConfig(TIM1, TIM_ExtTRGPSC_OFF, TIM_ExtTRGPolarity_NonInverted, 0);

  TIM_ClearOC1Ref (TIM1, TIM_OCClear_Enable);

  TIM_ClearOC2Ref (TIM1, TIM_OCClear_Enable);

  TIM_ClearOC3Ref (TIM1, TIM_OCClear_Enable);

Do I have something missing please?

I'm using  Center-aligned Mode 2 as counter mode and PWM Mode 2 as output compare mode, to control my 3 phase motor. I need to clear the three pwm channel references when PE7 goes high.

Thanks in advance,

Terence

0 REPLIES 0