2014-10-17 09:40 AM
Dear All
I would like to start a discuss about STM32F4 series timers operation while learning and understanding. Please share your idea and experience to explain each red circles from number 1 in the attached picture Any one can have an idea of operation red circles 1 in the attached picture2014-10-17 11:02 AM
Not clocked at 42 MHz
/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Attachments/47046/Edge_Aligned_PWM_TIM3.png
there, nothing personal, but I'm not going to read and interpret the timer chapter(s) for you. You'll need to read the docs to yourself and decimate that significantly.2014-10-17 11:43 PM
Dear All
Following program get one error which is Timer.c(23): error: #268: declaration may not appear after executable statement in blockThe error point this line TIM_TimeBaseInitTypeDef timerInitStructure;-----------------------------------------------------------------------------------#include ''stm32f4xx.h''#include ''stm32f4xx_tim.h''void InitializeLEDs();void InitializeTimer2();void InitializeLEDs(){ GPIO_InitTypeDef GPIO_Structure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); GPIO_Structure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13; GPIO_Structure.GPIO_Mode = GPIO_Mode_OUT; GPIO_Structure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOD, &GPIO_Structure); GPIO_WriteBit(GPIOD, GPIO_Pin_12 | GPIO_Pin_13, Bit_RESET);}void InitializeTimer2(){ RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE); TIM_TimeBaseInitTypeDef timerInitStructure; timerInitStructure.TIM_Prescaler = (uint16_t) (((SystemCoreClock / 1000000) / 2) - 1); timerInitStructure.TIM_CounterMode = TIM_CounterMode_Up; timerInitStructure.TIM_Period = 65535; timerInitStructure.TIM_ClockDivision = TIM_CKD_DIV1; timerInitStructure.TIM_RepetitionCounter = 0; TIM_TimeBaseInit(TIM2, &timerInitStructure); TIM_Cmd(TIM2, ENABLE);}int main (){ InitializeLEDs(); InitializeTimer2(); for (;;) { int timerValue = TIM_GetCounter(TIM2); if (timerValue == 400) GPIO_WriteBit(GPIOD, GPIO_Pin_12, Bit_SET); else if (timerValue == 500) GPIO_WriteBit(GPIOD, GPIO_Pin_12, Bit_RESET); } }2014-10-18 05:13 AM
2014-10-18 09:23 PM
Yes, as you pointed out the said Manual not well documented, that is the reason I decided to start this discussion
One of the first to get your head around is that there is a SINGLE counting element (ignoring the prescaler and repetition which have specific utility), the channels provide four latching/comparing elements, but do not count anything.Do you have experience with other timer devices, or silicon design implementation/understanding?Yes, I have enough experience of theory and practicals for 8 bit micro controller other than ARM.
I am expecting more advice from youThanks in advance