2015-11-19 10:03 AM
Hi,
I wanted to know how could I have 5V in a pin associated with a timer. I do this configuration:/*GPIOA Configuration: TIM9 CH1 (PA2)*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
If I try this pulling up with a resistor to 5V, I only get 3,3-3,5V in PA2. If I do the same but in Output Mode i get the 5V. So, how could I get 5V if the pin is in AF?
2015-11-19 11:47 AM
Hi,
Which microcontroller are you using?2015-11-19 12:30 PM
For a static signal, I wouldn't expect GPIO/AF to make a difference, the control signals are upstream from the drive transistors.
2015-11-20 02:11 AM
Hi,
Which microcontroller are you using? Sorry, I thought I had said that. I'm using stm32f4-disco.For a static signal
... Well I don't want a static signal I'm associating pin PA2 to TIM9 to make a square signal. I do like this:void TIM9_Configuration(void)
{
TIM_OCInitTypeDef TIM_OCInitStructure;
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
uint16_t Period;
Period = 100000 / 10; // 10 Hz for 100kHz prescalled
/* Time base configuration */
TIM_TimeBaseStructure.TIM_Prescaler = (SystemCoreClock / 100000) - 1;
TIM_TimeBaseStructure.TIM_Period = Period - 1;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM9, &TIM_TimeBaseStructure);
/* Enable TIM9 Preload register on ARR */
TIM_ARRPreloadConfig(TIM9, ENABLE);
/* TIM PWM1 Mode configuration */
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = Period / 2; // 50%
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
/* Output Compare PWM1 Mode configuration: Channel1 PA.02 */
TIM_OC1Init(TIM9, &TIM_OCInitStructure);
TIM_OC1PreloadConfig(TIM9, TIM_OCPreload_Enable);
/* TIM9 Main Output Enable */
TIM_CtrlPWMOutputs(TIM9, ENABLE);
/* TIM9 enable counter */
TIM_Cmd(TIM9, ENABLE);
}