2015-03-09 09:56 AM
I can't understand how come TIM1 frequency is 42 MHz.
Here is my config: 12 MHz HSE -> 168 MHz PLLCLK (MCO/4 = 42 MHz, checked) APB1 prescaler = 4 APB2 prescaler = 2 so TIM1, as it clocked from APB2 x 2 frequency should be 168 MHz. But output (GPIO^PIN in update interrupt) generates 0.21 MHz frequency 0.21x100x2 = 42MHz. RCC_PCLK1Config(RCC_HCLK_Div4); RCC_PCLK2Config(RCC_HCLK_Div2); RCC_HCLKConfig(RCC_SYSCLK_Div1); TIM_TimeBaseStructure.TIM_Period = 99; TIM_TimeBaseStructure.TIM_Prescaler = 0; TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure); #tim #stm322015-03-09 11:43 AM
Odd, what do you see with this?
TIM_TimeBaseStructure.TIM_Period = 999;
TIM_TimeBaseStructure.TIM_Prescaler = 0;
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure);
2015-03-09 11:43 AM
> (GPIO^PIN in update interrupt)
OK, so how long (in seconds or microseconds) does the pin remain in LOW state? And how long does it remain in HIGH state? The frequency is inverse of the WHOLE period, i.e. tLOW + tHIGH. JW2015-03-10 02:24 AM
Thank you so much!
Problem was inTIM_TimeBaseStructure.TIM_RepetitionCounter = 0;