2014-10-25 06:36 AM
Hello everyone.
I use STM32F4 Discovery. When I config timer (Time base) GPIO peripherals does not work. Timer is work, and GPIO is work (widthout timer configuration).Where is a problem?Best regards.2014-10-25 06:43 AM
2014-10-25 07:00 AM
Do you service the interrupt? What does the debugger suggest?
2014-10-25 07:08 AM
2014-10-25 07:54 AM
I connected LED on D0 and LED is lighting. In debug mode, after this...
TIM_ITConfig(TIM7, TIM_IT_Update, ENABLE);
LED is off.2014-10-25 08:19 AM
So are we supposed to randomly guess what you're doing until we figure it out?
Present the code that illustrates your problem. You need to make sure you correctly configure the timebase and the output channel modes, along with the pins and the AF muxing. Make sure to initialize all fields of the timer functions, local/auto variables may contain random junk on the stack, and this can lead to undefined operation.2014-10-25 08:22 AM
Is printf() under interrupt a good plan. It is rather slow and assumes you're sending the data somewhere.
2014-10-25 08:33 AM
#include ''stm32f4xx.h''
#include ''stm32f4xx_syscfg.h''#include ''stm32f4xx_rcc.h''#include ''stm32f4xx_gpio.h''#include ''stm32f4xx_exti.h''#include ''stm32f4xx_tim.h''#include ''misc.h''void Timer_Config(void){ TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; NVIC_InitTypeDef NVIC_InitStructure; RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); TIM_TimeBaseStructure.TIM_Prescaler = 84 - 1; TIM_TimeBaseStructure.TIM_Period = 1000 - 1; TIM_TimeBaseStructure.TIM_ClockDivision = 0; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); TIM_ITConfig(TIM3, TIM_IT_Update, ENABLE); TIM_Cmd(TIM3, ENABLE); }void LED_Config(void){ GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; GPIO_Init(GPIOD, &GPIO_InitStructure);}void TIM3_IRQHandler(void){ TIM_ClearITPendingBit(TIM3, TIM_IT_Update);}int main(){ Timer_Config(); LED_Config(); GPIOD->BSRRL = GPIO_Pin_0; while(1) { }}2014-10-25 08:53 AM
That code isn't going to do anything with the pin now is it? Perhaps you should toggle in the interrupt, and then scope if the frequency is too high to perceive.
2014-10-25 09:30 AM
Timer starts AD conversion on external ADC when LED=1 (LED is indicator). But, when timer is configuration, GPIO does not work. I put code for LED on in timer, but this is not solution. In this example, LED on is in the main because understanding a problem with GPIO.