2013-07-02 04:44 PM
Hi all,
i'm using STM32F407 with 12MHz ext. crystal with 168MHz system clock, i use demo for STM32F4Discovery, i configured Timer4 and Timer8 in same way, specifically: ARR=1, PSC=0, CKD=0, and i'm measuring 42MHz on both timers, is it something worng configured ? Timer8 is on APB2 so it should be twice faster than Timer4 , shouldn't be ? please help me to understand, Kind regards,2013-07-02 06:02 PM
2013-07-03 12:41 AM
so , during normal run i see registers:
RCC_CFGR: 0000940A CR: 0F039783 PLLCFGR: 0740540C and it corresponds this source: /* HCLK = SYSCLK / 1*/ RCC->CFGR |= RCC_CFGR_HPRE_DIV1; /* PCLK2 = HCLK / 2*/ RCC->CFGR |= RCC_CFGR_PPRE2_DIV2; /* PCLK1 = HCLK / 4*/ RCC->CFGR |= RCC_CFGR_PPRE1_DIV4; in docs is written that sysclk could be maximum 168MHz, APB2 84MHz (so it's DIV2 ), APB1 42MHz (so it's DIV4) update: i tried to change from DIV2-> DIV4: RCC->CFGR |= RCC_CFGR_PPRE2_DIV4; so register changed: RCC_CFGR: 0000B40A but i still measure 42MHz on both :( nothing changed :( is there something wrong ?2013-07-03 01:53 AM
Post a minimal but complete, compilable example of code exhibiting the problem.
JW2013-07-03 02:18 AM
well PLL initialization is from demo, i didn't change anything,
here is code for timers: GPIO_InitTypeDef GPIO_InitStructure; RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOD, ENABLE); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15 | GPIO_Pin_14; GPIO_Init( GPIOD , &GPIO_InitStructure); RCC_APB1PeriphClockCmd( RCC_APB1Periph_TIM4, ENABLE); GPIO_PinAFConfig( GPIOD, GPIO_PinSource14, GPIO_AF_TIM4 ); GPIO_PinAFConfig( GPIOD, GPIO_PinSource15, GPIO_AF_TIM4 ); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15 | GPIO_Pin_14; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_Init( GPIOD , &GPIO_InitStructure); RCC_APB2PeriphClockCmd( RCC_APB2Periph_TIM8, ENABLE); RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOC , ENABLE); GPIO_PinAFConfig( GPIOD, GPIO_PinSource6, GPIO_AF_TIM8 ); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_Init( GPIOC , &GPIO_InitStructure); #define ADC_CLK_TIM TIM4 #define ADC_CLK_TIM_ALT TIM8 TIM_Cmd( ADC_CLK_TIM, DISABLE); TIM_CtrlPWMOutputs( ADC_CLK_TIM, DISABLE ); TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; TIM_OCInitTypeDef TIM_OCInitStructure; TIM_TimeBaseStructure.TIM_Period = 1; TIM_TimeBaseStructure.TIM_Prescaler = 0x00; TIM_TimeBaseStructure.TIM_ClockDivision = 0; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit( ADC_CLK_TIM, &TIM_TimeBaseStructure); TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; TIM_OCInitStructure.TIM_Pulse = 1; /* Duty cycle: 50%*/ TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; TIM_OC3Init( ADC_CLK_TIM, &TIM_OCInitStructure); TIM_OC3PreloadConfig( ADC_CLK_TIM, TIM_OCPreload_Enable); TIM_OC4Init( ADC_CLK_TIM, &TIM_OCInitStructure); TIM_OC4PreloadConfig( ADC_CLK_TIM, TIM_OCPreload_Enable); TIM_CtrlPWMOutputs( ADC_CLK_TIM, ENABLE ); TIM_Cmd( ADC_CLK_TIM, ENABLE); TIM_TimeBaseInit( ADC_CLK_TIM_ALT, &TIM_TimeBaseStructure); TIM_OC1Init( ADC_CLK_TIM_ALT, &TIM_OCInitStructure); TIM_OC1PreloadConfig( ADC_CLK_TIM_ALT, TIM_OCPreload_Enable); TIM_CtrlPWMOutputs( ADC_CLK_TIM_ALT, ENABLE ); TIM_Cmd( ADC_CLK_TIM_ALT, ENABLE);2013-07-03 03:09 AM
> GPIO_PinAFConfig( GPIOD, GPIO_PinSource6, GPIO_AF_TIM8 );
? JW2013-07-03 03:48 AM
oh :( .........................................................................
......................... wrong initialization :( so issue solved, thank You,