cancel
Showing results for 
Search instead for 
Did you mean: 

TIM1 CH1 output generation on PA8 STM32F100C8

marbel
Associate II
Posted on July 05, 2012 at 12:05

Hi!

I have extensivly searched the forum and tried several code examples found here inorder to get this resolved. I have worked with STM32s for about two years and never had any problems with generating a simple PWM / OC pulse before.

I am trying to generate ANY kind of pulse from TIM1 Channel 1 on PA8 on a STM32F100C8, LQFP48.

No matter what i do, i will always get a steady state on either high or low ( I can change that by inserting TIM_CtrlPWMOutputs(TIM1, ENABLE); in the end of the code) . The pin is connected  directly to a testpoint with no other connections to that trace.

I have tried and faild to get this running under the latest version of atollic, coocox and IAR.

I am using version 3.5.0 of the system libraries.

My own guess is that it has to do with the fact that it is generation on a advanced timer (TIM1) but as i cant even get the TIM1_Syncro example to run, it seems like something that is more closely related to this device.

Does anyone have a working example of a TIM1 generated pulse on PA8 on a STM32F100C8?

Best regards

Martin

#output-compare #timer #tim1 #pwm
8 REPLIES 8
Posted on July 05, 2012 at 13:11

Absent code to review, I'm going to assume you have missed a couple of structure fields critical to TIM1 and TIM8.

Make sure to use this before setting your values into this structure

TIM_OCStructInit(&TIM_OCInitStructure);

..

  TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;

  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;

  TIM_OCInitStructure.TIM_Pulse = CCR1_Val;

  TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;

  TIM_OC1Init(TIM1, &TIM_OCInitStructure);

  TIM_OC1PreloadConfig(TIM1, TIM_OCPreload_Enable);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
marbel
Associate II
Posted on July 05, 2012 at 13:23

Hi Clive and thanks for your time.

Ok, i will provive one simple example. This code will attempt to output the same signal on both PA8 (TIM1 CH1) and PBB (TIM4 CH1) It is a modified version of the TIM_PWM example. It will give a signal on TIM4 CH1 but not TIM1 CH1.

/**
******************************************************************************
* @file TIM/OCActive/main.c
* @author MCD Application Team
* @version V3.5.0
* @date 08-April-2011
* @brief Main program body
******************************************************************************
* @attention
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include ''stm32f10x.h''
/** @addtogroup STM32F10x_StdPeriph_Examples
* @{
*/
/** @addtogroup TIM_OCActive
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
uint16_t CCR1_Val = 1000;
uint16_t CCR2_Val = 500;
uint16_t CCR3_Val = 250;
uint16_t CCR4_Val = 125;
uint16_t PrescalerValue = 0;
/* Private function prototypes -----------------------------------------------*/
void
RCC_Configuration(
void
);
void
GPIO_Configuration(
void
);
/* Private functions ---------------------------------------------------------*/
/**
* @brief Main program
* @param None
* @retval None
*/
int
main(
void
)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f10x_xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f10x.c file
*/
/* System Clocks Configuration */
RCC_Configuration();
/* Configure the GPIO ports */
GPIO_Configuration();
/* ---------------------------------------------------------------
TIM3 Configuration:
TIM3CLK = SystemCoreClock / 2,
The objective is to get TIM3 counter clock at 1 KHz:
- Prescaler = (TIM3CLK / TIM3 counter clock) - 1
And generate 4 signals with 4 different delays:
TIM3_CH1 delay = CCR1_Val/TIM3 counter clock = 1000 ms
TIM3_CH2 delay = CCR2_Val/TIM3 counter clock = 500 ms
TIM3_CH3 delay = CCR3_Val/TIM3 counter clock = 250 ms
TIM3_CH4 delay = CCR4_Val/TIM3 counter clock = 125 ms
* SystemCoreClock is set to 72 MHz for Low-density, Medium-density, High-density
and Connectivity line devices and to 24 MHz for Low-Density Value line and
Medium-Density Value line devices
--------------------------------------------------------------- */
/*Compute the prescaler value */
PrescalerValue = (uint16_t) (SystemCoreClock / 24000000) - 1;
/* Time base configuration */
TIM_TimeBaseStructure.TIM_Period = 30000;
TIM_TimeBaseStructure.TIM_Prescaler = PrescalerValue;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);
TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure);
/* PWM1 Mode configuration: Channel1 */
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = 3000;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OC1Init(TIM4, &TIM_OCInitStructure);
TIM_OC1Init(TIM1, &TIM_OCInitStructure);
TIM_OC1PreloadConfig(TIM4, TIM_OCPreload_Enable);
TIM_OC1PreloadConfig(TIM1, TIM_OCPreload_Enable);
TIM_ARRPreloadConfig(TIM4, ENABLE);
TIM_ARRPreloadConfig(TIM1, ENABLE);
/* TIM4 enable counter */
TIM_Cmd(TIM4, ENABLE);
TIM_Cmd(TIM1, ENABLE);
while
(1)
{}
}
/**
* @brief Configures the different system clocks.
* @param None
* @retval None
*/
void
RCC_Configuration(
void
)
{
/* PCLK1 = HCLK/4 */
RCC_PCLK1Config(RCC_HCLK_Div4);
/* TIM3 clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE);
/* GPIOA and GPIOC clock enable */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOA |
RCC_APB2Periph_AFIO, ENABLE);
}
/**
* @brief Configure the TIM3 and the GPIOE Pins.
* @param None
* @retval None
*/
void
GPIO_Configuration(
void
)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* GPIOA Configuration:TIM3 Channel1, 2, 3 and 4 as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void
assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf(''Wrong parameters value: file %s on line %d

'', file, line) */
while
(1)
{}
}
#endif
/**
* @}
*/
/**
* @}
*/
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/

Best regards Martin
Posted on July 05, 2012 at 14:30

/**
******************************************************************************
* @file TIM/OCActive/main.c
* @author MCD Application Team
* @version V3.5.0
* @date 08-April-2011
* @brief Main program body
******************************************************************************
* @attention
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <
h2
><
center
>© COPYRIGHT 2011 STMicroelectronics</
center
></
h2
>
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include ''stm32f10x.h''
/** @addtogroup STM32F10x_StdPeriph_Examples
* @{
*/
/** @addtogroup TIM_OCActive
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
uint16_t CCR1_Val = 1000;
uint16_t CCR2_Val = 500;
uint16_t CCR3_Val = 250;
uint16_t CCR4_Val = 125;
uint16_t PrescalerValue = 0;
/* Private function prototypes -----------------------------------------------*/
void RCC_Configuration(void);
void GPIO_Configuration(void);
/* Private functions ---------------------------------------------------------*/
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f10x_xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f10x.c file
*/
/* System Clocks Configuration */
RCC_Configuration();
/* Configure the GPIO ports */
GPIO_Configuration();
/* ---------------------------------------------------------------
TIM3 Configuration:
TIM3CLK = SystemCoreClock / 2,
The objective is to get TIM3 counter clock at 1 KHz:
- Prescaler = (TIM3CLK / TIM3 counter clock) - 1
And generate 4 signals with 4 different delays:
TIM3_CH1 delay = CCR1_Val/TIM3 counter clock = 1000 ms
TIM3_CH2 delay = CCR2_Val/TIM3 counter clock = 500 ms
TIM3_CH3 delay = CCR3_Val/TIM3 counter clock = 250 ms
TIM3_CH4 delay = CCR4_Val/TIM3 counter clock = 125 ms
* SystemCoreClock is set to 72 MHz for Low-density, Medium-density, High-density
and Connectivity line devices and to 24 MHz for Low-Density Value line and
Medium-Density Value line devices
--------------------------------------------------------------- */
/*Compute the prescaler value */
PrescalerValue = (uint16_t) (SystemCoreClock / 24000000) - 1;
/* Time base configuration */
TIM_TimeBaseStructure.TIM_Period = 30000 - 1; // ie 0..29999

TIM_TimeBaseStructure.TIM_Prescaler = PrescalerValue;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);
TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure);
TIM_OCStructInit(&TIM_OCInitStructure); // clears the other 4 fields not used here
/* PWM1 Mode configuration: Channel1 */
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = 3000;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OC1Init(TIM4, &TIM_OCInitStructure);
TIM_OC1Init(TIM1, &TIM_OCInitStructure);
TIM_OC1PreloadConfig(TIM4, TIM_OCPreload_Enable);
TIM_OC1PreloadConfig(TIM1, TIM_OCPreload_Enable);
TIM_ARRPreloadConfig(TIM4, ENABLE);
TIM_ARRPreloadConfig(TIM1, ENABLE);
/* TIM Main Output Enable */
TIM_CtrlPWMOutputs(TIM4, ENABLE);
TIM_CtrlPWMOutputs(TIM1, ENABLE);
/* TIM enable counter */
TIM_Cmd(TIM4, ENABLE);
TIM_Cmd(TIM1, ENABLE);
while (1)
{}
}
/**
* @brief Configures the different system clocks.
* @param None
* @retval None
*/
void RCC_Configuration(void)
{
/* PCLK1 = HCLK/4 */
RCC_PCLK1Config(RCC_HCLK_Div4);
/* TIM3 clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE);
/* GPIOA and GPIOC clock enable */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOA |
RCC_APB2Periph_AFIO, ENABLE);
}
/**
* @brief Configure the TIM3 and the GPIOE Pins.
* @param None
* @retval None
*/
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* GPIOA Configuration:TIM3 Channel1, 2, 3 and 4 as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf(''Wrong parameters value: file %s on line %d

'', file, line) */
while (1)
{}
}
#endif
/**
* @}
*/
/**
* @}
*/
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
marbel
Associate II
Posted on July 05, 2012 at 14:49

Thanks Clive. 

I was about to go crazy and am also still very confused to why this happend.I tried so many configurations and none of them worked. 

// Martin

Posted on July 05, 2012 at 15:56

TIM1 and TIM8 are special, having negated outputs on THREE channels, and idle states. You usually don't use these, or see them in examples, zeroing out the structure or having them contain random stack junk, will often cause mysterious headaches or bizarre behaviour.

void TIM_OCStructInit(TIM_OCInitTypeDef* TIM_OCInitStruct)
{
/* Set the default configuration */
TIM_OCInitStruct->TIM_OCMode = TIM_OCMode_Timing;
TIM_OCInitStruct->TIM_OutputState = TIM_OutputState_Disable;
TIM_OCInitStruct->TIM_OutputNState = TIM_OutputNState_Disable;
TIM_OCInitStruct->TIM_Pulse = 0x0000;
TIM_OCInitStruct->TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OCInitStruct->TIM_OCNPolarity = TIM_OCPolarity_High;
TIM_OCInitStruct->TIM_OCIdleState = TIM_OCIdleState_Reset;
TIM_OCInitStruct->TIM_OCNIdleState = TIM_OCNIdleState_Reset;
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
marbel
Associate II
Posted on July 05, 2012 at 17:25

This was the reason. I tested to add these lines to some of the examples i had before and all of them was resolved.

Thanks!

Martin

abelloni
Associate II
Posted on December 15, 2013 at 16:42

Hi!

I have extensivly searched the forum and tried several code examples found here inorder to get this resolved. I have worked with STM32s for about two years and never had any problems with generating a simple PWM / OC pulse before.

I am trying to generate ANY kind of pulse from TIM1 Channel 1 on PA8 on a STM32F100C8, LQFP48.

No matter what i do, i will always get a steady state on either high or low ( I can change that by inserting TIM_CtrlPWMOutputs(TIM1, ENABLE); in the end of the code) . The pin is connected  directly to a testpoint with no other connections to that trace.

I have tried and faild to get this running under the latest version of atollic, coocox and IAR.

I am using version 3.5.0 of the system libraries.

My own guess is that it has to do with the fact that it is generation on a advanced timer (TIM1) but as i cant even get the TIM1_Syncro example to run, it seems like something that is more closely related to this device.

Does anyone have a working example of a TIM1 generated pulse on PA8 on a STM32F100C8?

Best regards

Martin
abelloni
Associate II
Posted on December 15, 2013 at 16:43

Hi Clive and thanks for your time.

Ok, i will provive one simple example. This code will attempt to output the same signal on both PA8 (TIM1 CH1) and PBB (TIM4 CH1) It is a modified version of the TIM_PWM example. It will give a signal on TIM4 CH1 but not TIM1 CH1.

/**
******************************************************************************
* @file TIM/OCActive/main.c
* @author MCD Application Team
* @version V3.5.0
* @date 08-April-2011
* @brief Main program body
******************************************************************************
* @attention
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include ''stm32f10x.h''
/** @addtogroup STM32F10x_StdPeriph_Examples
* @{
*/
/** @addtogroup TIM_OCActive
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
uint16_t CCR1_Val = 1000;
uint16_t CCR2_Val = 500;
uint16_t CCR3_Val = 250;
uint16_t CCR4_Val = 125;
uint16_t PrescalerValue = 0;
/* Private function prototypes -----------------------------------------------*/
void
RCC_Configuration(
void
);
void
GPIO_Configuration(
void
);
/* Private functions ---------------------------------------------------------*/
/**
* @brief Main program
* @param None
* @retval None
*/
int
main(
void
)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f10x_xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f10x.c file
*/
/* System Clocks Configuration */
RCC_Configuration();
/* Configure the GPIO ports */
GPIO_Configuration();
/* ---------------------------------------------------------------
TIM3 Configuration:
TIM3CLK = SystemCoreClock / 2,
The objective is to get TIM3 counter clock at 1 KHz:
- Prescaler = (TIM3CLK / TIM3 counter clock) - 1
And generate 4 signals with 4 different delays:
TIM3_CH1 delay = CCR1_Val/TIM3 counter clock = 1000 ms
TIM3_CH2 delay = CCR2_Val/TIM3 counter clock = 500 ms
TIM3_CH3 delay = CCR3_Val/TIM3 counter clock = 250 ms
TIM3_CH4 delay = CCR4_Val/TIM3 counter clock = 125 ms
* SystemCoreClock is set to 72 MHz for Low-density, Medium-density, High-density
and Connectivity line devices and to 24 MHz for Low-Density Value line and
Medium-Density Value line devices
--------------------------------------------------------------- */
/*Compute the prescaler value */
PrescalerValue = (uint16_t) (SystemCoreClock / 24000000) - 1;
/* Time base configuration */
TIM_TimeBaseStructure.TIM_Period = 30000;
TIM_TimeBaseStructure.TIM_Prescaler = PrescalerValue;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);
TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure);
/* PWM1 Mode configuration: Channel1 */
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = 3000;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OC1Init(TIM4, &TIM_OCInitStructure);
TIM_OC1Init(TIM1, &TIM_OCInitStructure);
TIM_OC1PreloadConfig(TIM4, TIM_OCPreload_Enable);
TIM_OC1PreloadConfig(TIM1, TIM_OCPreload_Enable);
TIM_ARRPreloadConfig(TIM4, ENABLE);
TIM_ARRPreloadConfig(TIM1, ENABLE);
/* TIM4 enable counter */
TIM_Cmd(TIM4, ENABLE);
TIM_Cmd(TIM1, ENABLE);
while
(1)
{}
}
/**
* @brief Configures the different system clocks.
* @param None
* @retval None
*/
void
RCC_Configuration(
void
)
{
/* PCLK1 = HCLK/4 */
RCC_PCLK1Config(RCC_HCLK_Div4);
/* TIM3 clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE);
/* GPIOA and GPIOC clock enable */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOA |
RCC_APB2Periph_AFIO, ENABLE);
}
/**
* @brief Configure the TIM3 and the GPIOE Pins.
* @param None
* @retval None
*/
void
GPIO_Configuration(
void
)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* GPIOA Configuration:TIM3 Channel1, 2, 3 and 4 as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void
assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf(''Wrong parameters value: file %s on line %d

'', file, line) */
while
(1)
{}
}
#endif
/**
* @}
*/
/**
* @}
*/
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/

Best regards Martin