cancel
Showing results for 
Search instead for 
Did you mean: 

reading pwm inputs

srinath3142
Associate
Posted on November 11, 2011 at 10:08

Hi everyone

I have some silly newbie doubts on stm32f2 series

I had downloaded the standard peripheral library and was looking at the sample codes in 

\STM32F4xx_DSP_StdPeriph_Lib_V1.0.0\Project\STM32F4xx_StdPeriph_Examples\TIM\PWM_Input

My doubt is in the lines

GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

  GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP ;

When we want to read a pwm signal, why are we setting the pin as an output?

Thanks

Srinath

2 REPLIES 2
Posted on November 11, 2011 at 18:21

When we want to read a pwm signal, why are we setting the pin as an output?

 

It's not so much that it's an output, but that it is NOT controlled by the GPIO unit. Alternate function devices with bidirectional functionality, or ambiguous internal configurations, will in fact control the ''Output Control'' portion of the pin driver shown in the documentation.

For example all the SPI projects dating back to the F1 series set all pins as ''AF OUT'' and the peripheral controls the details based on the slave/master/1-wire/2-wire configurations.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
srinath3142
Associate
Posted on November 11, 2011 at 20:19

Thanks Clive.

Are the following 2 lines necessary or should they always be set as follows for AF mode?

GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP ;