AnsweredAssumed Answered

How to Configura TIM1CLK TIMXCLK

Question asked by siqueira.erisson on Jul 10, 2012
Latest reply on Jul 10, 2012 by siqueira.erisson

According to the attached. I do not understand how to set the clock correctly TIMER From what I understand, TIMXCLK PCLK1 = 2 * and 2 * = TIM1CLK PCLK2 But not found in the manual or the information in the datasheet. Can anyone help me?


void vConfigura_RCC(void)
{
 RCC_DeInit();             // Deinitialize RCC
 RCC_HSEConfig(RCC_HSE_ON);           // Enable HSE (external crystal)
 HSEStartUpStatus = RCC_WaitForHSEStartUp();       // Wait till HSE is ready
 
 if (HSEStartUpStatus == SUCCESS)
 {  
  FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);   // Enable Prefetch Buffer
  FLASH_SetLatency(FLASH_Latency_2);       // Flash 2 wait state
  RCC_HCLKConfig(RCC_SYSCLK_Div1);       // HCLK = SYSCLK  = 72Mhz
  RCC_ADCCLKConfig(RCC_PCLK2_Div6);        // ADCCLK = PCLK2/6 = 12MHz
  RCC_PCLK2Config(RCC_HCLK_Div1);        // PCLK2 = HCLK  = 72Mhz
  RCC_PCLK1Config(RCC_HCLK_Div2);        // PCLK1 = HCLK / 2 = 36Mhz
  RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);  // PLLCLK = 8Mhz x 9 = 72Mhz
  RCC_PLLCmd(ENABLE);           // Enable PLL
  
  while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);  // Wait till PLL is ready
 
  RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);      // Select PLL as system clock source
                 
  while (RCC_GetSYSCLKSource() != 0x08);      // Wait till PLL is used as system clock source
 }

  /* PCLK1 = HCLK/4 */
  RCC_PCLK1Config(RCC_HCLK_Div8);   // Ajusta CLOCK dos Perifericos de APB1
  RCC_PCLK2Config(RCC_HCLK_Div8);   // Ajusta CLOCK dos Perifericos de APB2
 
  /* 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);
}

Outcomes