2017-10-21 10:26 PM
Hello.I use stm32f107vct6 and use this code for external mode for timer 3
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3 ,ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO, ENABLE);GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure);TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_TimeBaseStructure.TIM_Period = 1; TIM_TimeBaseStructure.TIM_Prescaler = 25; TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); TIM_SelectInputTrigger(TIM3, TIM_TS_TI1FP1); TIM_TIxExternalClockConfig (TIM3, TIM_TS_TI1FP1, TIM_ICPolarity_Rising, 0) ; TIM_SelectSlaveMode(TIM3, TIM_SlaveMode_External1); TIM_ITConfig(TIM3, TIM_IT_Update, ENABLE); NVIC_InitTypeDef NVIC_InitStructure;/* Enable the TIM1 global Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); TIM_Cmd(TIM3,ENABLE);It work correctly but now i want use stm32f103c8 and i use exactly this code but it's not work(change internal pulse ) .whats different between them?
how can i fix this problem?
Solved! Go to Solution.
2017-10-22 08:44 AM
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP;
Consider using GPIO_Mode_IN_FLOATING for an INPUT
2017-10-22 01:56 AM
Hello Mahmoud Boroumand,
Looking at the part numbers, which you mentioned, it seems that you skipped one sign in their names:
Regarding stm32f07vct6, there is a missing sing between 7 and v, so it should be something like
stm32f07
?
vct6Regarding stm32f03c8, situation is similar, so there is a missing sing between 3 and c - stm32f03
?
c8Could you please double check the devices, which you use and provide here their full names? This can help to answer your question.
Regards
Szymon2017-10-22 04:07 AM
Hello
sorry
stm32f103c8
and
stm32f107vct6
2017-10-22 04:28 AM
Period = 1 ?? Not going to count very much
Clocking code in system_stm32f1xx.c going to differ between 103 and 107 series parts, check input clock, PLL settings.
Consider using PA8 as MCO to probe internal clocks.
Double check pin utilization in data sheets for two parts.
Not Working? What type of input is being applied, and what happens in the work vs not-working case? What are the register settings in TIM3 when you dump out or view in debugger?
2017-10-22 08:30 AM
Hello I have to change my timer to timer 1 and this is my code
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1 ,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO, ENABLE); // GPIO_PinRemapConfig(GPIO_FullRemap_TIM3,ENABLE);GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; TIM_TimeBaseStructure.TIM_Period = 1; TIM_TimeBaseStructure.TIM_Prescaler = 25; TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseStructure.TIM_RepetitionCounter=0; TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure); TIM_ARRPreloadConfig(TIM1,ENABLE); TIM_SelectInputTrigger(TIM1, TIM_TS_TI1FP1); TIM_TIxExternalClockConfig (TIM1, TIM_TS_TI1FP1, TIM_ICPolarity_BothEdge, 0) ; TIM_SelectSlaveMode(TIM1, TIM_SlaveMode_External1); TIM_ITConfig(TIM1, TIM_IT_Update, ENABLE); NVIC_InitTypeDef NVIC_InitStructure;/* Enable the TIM1 global Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = TIM1_UP_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); TIM_Cmd(TIM1,ENABLE);when i conncet pulse to pin a 8 the pulse change .
please help me.how can i fix it?
before connect to pin a 8
after connect to pin a 8
2017-10-22 08:44 AM
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP;
Consider using GPIO_Mode_IN_FLOATING for an INPUT