AnsweredAssumed Answered

Missing TIM4 definition??

Question asked by Tom on Apr 22, 2014
Latest reply on Apr 24, 2014 by Tom
Hello All,

I trying the following configuration of TIM4 on STM32L152


01.void Timer4Init(void) {
02. 
03.    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
04. 
05.// Zero cross in - counter start  CH3 PB8
06. 
07.      GPIO_InitStructure.GPIO_Pin =  ZERO_CROSS_TIM4_IN_PIN;
08.      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
09.      GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;
10.      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
11.      GPIO_Init(ZERO_CROSS_TIM4_IN_PORT, &GPIO_InitStructure);
12. 
13.      GPIO_PinAFConfig(ZERO_CROSS_TIM4_IN_PORT, ZERO_CROSS_TIM4_IN_PIN_SOURCE, GPIO_AF_TIM4);
14. 
15. 
16.     /* Time base configuration -----------------------------------------------*/
17.      TIM_TimeBaseStructure.TIM_Period = 10;
18.      TIM_TimeBaseStructure.TIM_Prescaler = 20;
19.      TIM_TimeBaseStructure.TIM_ClockDivision = 0;
20.      TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
21. 
22.      TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);
23. 
24.      /* TIM4 PWM2 Mode configuration: Channel1 -----------------------------------------------*/
25.      TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2;
26.      TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Disable; //no GPIO output
27.      TIM_OCInitStructure.TIM_Pulse = 1; //short impuls
28.      TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
29. 
30.      TIM_OC1Init(TIM4, &TIM_OCInitStructure);
31. 
32.      /*  configuration in Input Capture Mode -----------------------------------------------*/
33. 
34.      //falling edge on  PB8 starts timer
35. 
36.      TIM_ICStructInit(&TIM_ICInitStructure);
37. 
38.      TIM_ICInitStructure.TIM_Channel = TIM_Channel_3;
39.      TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Falling;
40.      TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
41.      TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
42.      TIM_ICInitStructure.TIM_ICFilter = 0;
43.      TIM_ICInit(TIM4, &TIM_ICInitStructure);
44. 
45.      /* One Pulse Mode selection */
46.      TIM_SelectOnePulseMode(TIM4, TIM_OPMode_Single);
47. 
48.      /* Input Trigger selection ----------------------------------------------- */
49.      TIM_SelectInputTrigger(TIM4, TIM_TS_TI3FP3);
50. 
51.      /* Slave Mode selection: Trigger Mode */
52.      TIM_SelectSlaveMode(TIM4, TIM_SlaveMode_Trigger);
53. 
54. 
55.      Timer4DMAInit();
56. 
57. 
58.}

and I'm getting errors on line: 

49.      TIM_SelectInputTrigger(TIM4, TIM_TS_TI3FP3);

TIM_TS_TI3FP3 is undefined but in datasheet RM0038 (page 341) I see it should be defined (see attached image).

What am I missing here?

thanks and regards
Tom

 









Attachments

Outcomes