AnsweredAssumed Answered

SOLVED!!! One Pulse on TIM15 on STM32F072/STM32072B-EVAL

Question asked by grimes.robert on Sep 3, 2014
Latest reply on Sep 5, 2014 by waclawek.jan
Hi,

I'm trying to modify the standard One Pulse example to use TIM15 to generate a delay, programmable width pulse, triggered by an external input.  For the external input, I am using TIM3 routed to the appropriate pin (PA3) which is TIM15_CH2.  I am looking at TIM15_CH1.  The TIM3 output is working, generating an ~45 Hz trigger signal.  However, I cannot get anything on the output of TIM15_CH1 (on PA2).  Here is my code for TIM15:

01.static void TIM_Config(void)
02.{
03.  TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
04.  TIM_ICInitTypeDef  TIM_ICInitStructure;
05.  TIM_OCInitTypeDef  TIM_OCInitStructure;
06.  GPIO_InitTypeDef GPIO_InitStructure;
07. 
08.  /* TIM15 clock enable */
09.  RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM15, ENABLE);
10. 
11.  /* GPIOA clock enable */
12.  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
13.   
14.  /* TIM15_CH1 pin (PA.02) and TIM15_CH2 pin (PA.03) configuration */
15.  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3;
16.  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
17.  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
18.  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
19.  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
20.  GPIO_Init(GPIOA, &GPIO_InitStructure);
21. 
22.  /* Connect TIM pins to AF0 */
23.  GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_0);
24.  GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_0);
25. 
26.  /* --------------------------------------------------------------------------
27.    TIM15 configuration: One Pulse mode
28.    The external signal is connected to TIM15_CH2 pin (PA03),
29.    The Rising edge is used as active edge,
30.    The One Pulse signal is output on TIM15_CH1 pin (PA02)
31.    The TIM_Pulse defines the delay value
32.    The (TIM_Period -  TIM_Pulse) defines the One Pulse value.
33.  --------------------------------------------------------------------------- */
34. 
35.  /* Compute the prescaler value */
36.  PrescalerValue = (uint16_t) ((SystemCoreClock ) / 24000000) - 1;
37.   
38.  /* Time base configuration */
39.  TIM_TimeBaseStructure.TIM_Period = 65535;
40.  TIM_TimeBaseStructure.TIM_Prescaler = PrescalerValue;
41.  TIM_TimeBaseStructure.TIM_ClockDivision = 0;
42.  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
43.  TIM_TimeBaseInit(TIM15, &TIM_TimeBaseStructure);
44. 
45.  /* TIM15 PWM2 Mode configuration: Channel1 */
46.  TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2;
47.  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
48.  TIM_OCInitStructure.TIM_Pulse = 16383;
49.  TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
50.  TIM_OC1Init(TIM15, &TIM_OCInitStructure);
51. 
52.  /* TIM configuration in Input Capture Mode */
53.  TIM_ICStructInit(&TIM_ICInitStructure);
54.  TIM_ICInitStructure.TIM_Channel = TIM_Channel_2;
55.  TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
56.  TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
57.  TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
58.  TIM_ICInitStructure.TIM_ICFilter = 0;
59.  TIM_ICInit(TIM15, &TIM_ICInitStructure);
60. 
61.  /* One Pulse Mode selection */
62.  TIM_SelectOnePulseMode(TIM15, TIM_OPMode_Single);
63. 
64.  /* Input Trigger selection */
65.  TIM_SelectInputTrigger(TIM15, TIM_TS_TI2FP2);
66. 
67.  /* Slave Mode selection: Trigger Mode */
68.  TIM_SelectSlaveMode(TIM15, TIM_SlaveMode_Trigger);
69.  TIM_Cmd(TIM15, ENABLE);
70.}

It seems I am missing something - probably trivial!  Any ideas?

Thanks!

Outcomes