AnsweredAssumed Answered

TIM4 PWM PROBLEM STM32F3DISCOVERY: PLL_SOURCE_HSE_BYPASS ?

Question asked by spiezia.andrea on Dec 29, 2015
Latest reply on Jan 4, 2016 by spiezia.andrea
Hi all,
I've downloaded the following simple code in my STM32F3DISCOVERY but I don't see anything. Should be a sistem clock config problem?

In main.c:

#include "stm32f30x.h"
 
/***************************************/
 
void RCC_Configuration(void)
{
  /* Enable GPIO clock */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
 
  /* Enable TIM3/4 clock */
  RCC_APB1PeriphClockCmd( RCC_APB1Periph_TIM4, ENABLE);
}
 
/************************/
 
void GPIO_Configuration(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;
 
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_10); // TIM4_CH1
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_10); // TIM4_CH2
 
  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_11 | GPIO_Pin_12;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
}
 
/************************************/
 
void TIM_Configuration(void)
{
  TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
  TIM_OCInitTypeDef TIM_OCInitStructure;
 
  TIM_TimeBaseStructure.TIM_Prescaler = 72 - 1; // 72 to 1 MHz
  TIM_TimeBaseStructure.TIM_Period = 10 - 1; // 1 MHz to 100 KHz
  TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
 
  TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);
 
  TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
  TIM_OCInitStructure.TIM_Pulse = 10 / 4; // 25%
  TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
 
  TIM_OC1Init(TIM4, &TIM_OCInitStructure);
  TIM_OC2Init(TIM4, &TIM_OCInitStructure);
 
  TIM_Cmd(TIM4, ENABLE);
 }
 
/**************************************/
 
int main(void)
{
  RCC_Configuration();
 
  GPIO_Configuration();
 
  TIM_Configuration();
 
  while(1); // Don't want to exit
}

and I've this in system_stm32f30x.c :

/* Select the PLL clock source */


//#define PLL_SOURCE_HSI        // HSI (~8MHz) used to clock the PLL, and the PLL is used as system clock source
//#define PLL_SOURCE_HSE        // HSE (8MHz) used to clock the PLL, and the PLL is used as system clock source
#define PLL_SOURCE_HSE_BYPASS // HSE bypassed with an external clock (8MHz, coming from ST-Link) used to clock
 
Can you help me?

Thanks in advantage.

Outcomes