cancel
Showing results for 
Search instead for 
Did you mean: 

Want to change to TIM9_CH1 point to PE5 in STM32Cube_FW_F4_V1.1.0\Projects\STM324x9I_EVAL\Examples\TIM\TIM_PWMOutput

Linda
Associate II
Posted on June 19, 2014 at 04:54

I want to change to TIM9_CH1 point to PE5 in STM32Cube_FW_F4_V1.1.0\Projects\STM324x9I_EVAL\Examples\TIM\TIM_PWMOutput. The main.h is:

~~~~~~~~~~

#define TIMx                           TIM3

#define TIMx_CLK_ENABLE                __TIM3_CLK_ENABLE

/* Definition for USARTx Pins */

#define TIMx_CHANNEL_GPIO_PORT()       __GPIOC_CLK_ENABLE()

#define GPIO_PIN_CHANNEL1              GPIO_PIN_6

#define GPIO_PIN_CHANNEL2              GPIO_PIN_7

#define GPIO_PIN_CHANNEL3              GPIO_PIN_8

#define GPIO_PIN_CHANNEL4              GPIO_PIN_9

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I change it to:

~~~~~~~~~~~~~~~~~~~~~~~~~~

#define TIMx                           TIM9

#define TIMx_CLK_ENABLE                __TIM9_CLK_ENABLE

/* Definition for USARTx Pins */

#define TIMx_CHANNEL_GPIO_PORT()       __GPIOE_CLK_ENABLE()

#define GPIO_PIN_CHANNEL1              GPIO_PIN_5

#define GPIO_PIN_CHANNEL2              GPIO_PIN_7

#define GPIO_PIN_CHANNEL3              GPIO_PIN_8

#define GPIO_PIN_CHANNEL4              GPIO_PIN_9

~~~~~~~~~~~~~~~~~~~~~

But it doesn't work.

Please help.

Thanks
4 REPLIES 4
Linda
Associate II
Posted on June 20, 2014 at 12:09

Please help, why it can not be pointed to other port?

Posted on June 20, 2014 at 15:15

Probably because there are other dependencies within the code tree that these defines don't address. You're going to need to learn to walk through the code to understand it.

STM32Cube_FW_F4_V1.0.0\Projects\STM324x9I_EVAL\Examples\TIM\TIM_PWMOutput\Src\stm32f4xx_hal_msp.c Makes specific reference to GPIOC when initializing the pins, and TIM3

void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim)
{
GPIO_InitTypeDef GPIO_InitStruct;
/*##-1- Enable peripherals and GPIO Clocks #################################*/
/* TIMx Peripheral clock enable */
TIMx_CLK_ENABLE();
/* Enable GPIO Channels Clock */
TIMx_CHANNEL_GPIO_PORT();
/*##-2- Configure I/Os #####################################################*/
/* Configure PC.6 (TIM3_Channel1), PC.7 (TIM3_Channel2), PC.8 (TIM3_Channel3),
PC.9 (TIM3_Channel4) in output, push-pull, alternate function mode
*/
/* Common configuration for all channels */
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF2_TIM3;
GPIO_InitStruct.Pin = GPIO_PIN_CHANNEL1;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_CHANNEL2;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_CHANNEL3;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_CHANNEL4;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
}

Your life might also be a lot easier if you use the Standard Library rather than the HAL/CUBE thing.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
raptorhal2
Lead
Posted on June 20, 2014 at 15:20

Another possibility - PE 7, 8, and 9 are not TIM9 channels.

Cheers, Hal

Posted on June 20, 2014 at 19:21

Another possibility - PE 7, 8, and 9 are not TIM9 channels.

It only has two channels, but the question really seems to be about CH1

These kinds of half-assed examples, here and in the standard library do annoy me. It's like look here I have these defines to abstract the pins/peripheral on some hardware platforms, but then it breaks because the abstraction is incomplete, or there is some assumption about APB1 or APB2 that's hard coded deeper in the configuration routine.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..