2016-10-05 11:26 PM
Dear Sir,
While configuring STM32cubemx, my design does not contain any TIM1 or else.Now I am confused how should I configure Timer application for GPIO or other things.According to this vedio,https://www.youtube.com/watch?v=_wE7tbilca4&list=PLDin7xWrqlc-gJUiyHNHpfm9wjbsPBz5y&index=5timer can be applicable for input capture.You suggest me to apply systick in this case.What should I do now ?Look at this code kindly,void SysTick_Handler(void){ static uint32_t time = 0; time++; if ((time > 0) && (time <= 5)){ write_digit(1); write_led_7_segment(led_number[0]); } if ((time > 5) && (time <= 10)){ write_digit(2); write_led_7_segment(led_number[1]); } if ((time > 10) && (time <= 15)){ write_digit(3); write_led_7_segment(led_number[2]); } if ((time > 15) && (time <= 20)){ write_digit(4); write_led_7_segment(led_number[3]); if (time == 20){ time = 0; } }}2016-10-06 05:41 AM
I'm not a genie, and I don't do CubeMX/HAL coding support. Please don't tag me into threads.
Showing someone else's 7min video doesn't explain what *you* want to achieve with Input Capture in the SysTick. If you want to read buttons, configure them as GPIO Inputs, and look at the pin states in the interrupt. Or if you must use a TIM look at using it to cause Input Capture interrupts directly. Review tools like WinMerge if you need to combine source files that implement different features.2016-10-06 05:58 PM
Dear Sir,
Sorry to tag you here. I know you are expert. I need to see TIM look for Input Capture interrupts directly.For my circuit configuration, TIM1/2 is not active. I could you TIM6/7.2016-10-07 04:30 AM
Hi hasan.md_mubdiul,
Your description (device? hardware? ) and need are not enough clear (input capture, Systick -> unclear relation). Try to put also a significant title for your thread. What I understand: you need an input capture and TIM1 and TIM2 are not available.If an available timer has an IO pin on his channel, you can configure it as input capture (IC). Check the pinout section in the datasheet to see the available IO pin for Timer channels. To get help to code the input capture , you refer to the profided ready-to-use example in STM32Cube package relevant to the device that you use. ()-Hannibal-2016-10-10 05:46 PM
Dear Sir Hannibal,
Thank you to respond this post.I already been using 32STMcubemx to configure my MCU as it generates driver code.I am using stm32f070RB in a circuit board( not evaluation board) that is made for rice-cooker.My circuit is made such a way that I cant use TIM1 and TIM2.According to datasheet, TIM6 and TIM7 can be used as a generic 16-bit time base. I activated this 2 in cubemx, but not sure how to use them.People use in this way,void MX_TIM6_Init(void){ TIM_MasterConfigTypeDef sMasterConfig; htim6.Instance = TIM6; htim6.Init.Prescaler = 64; htim6.Init.CounterMode = TIM_COUNTERMODE_UP; htim6.Init.Period = 2625; HAL_TIM_Base_Init(&htim6); sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; HAL_TIMEx_MasterConfigSynchronization(&htim6, &sMasterConfig);}I am not sure TIM_TRGO should be use, cubemx did not generate this.Help me please. Do you think I should follow STM32Cube_FW_F0_V1.6.0 example like, TIM/TIM_InputCapture/Src/main.c ?2016-10-17 03:39 AM
Hi,
It is mentionned in relevant datasheet ()that These timers can be used as a generic 16-bit time base. ( page 20)Each die has the defined IO availability and characteristics.-Hannibal-2016-10-17 06:44 PM
Dear Sir,
Its written in user manual that TIM6/7 is not available for such MCU.I am using TIM14, but cant understand how to make logical pwm.Take a look. /* TIM14 init function */ static void MX_TIM14_Init(void) { TIM_IC_InitTypeDef sConfigIC; htim14.Instance = TIM14; htim14.Init.Prescaler = 0; htim14.Init.CounterMode = TIM_COUNTERMODE_UP; htim14.Init.Period = 0; htim14.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; if (HAL_TIM_Base_Init(&htim14) != HAL_OK) { Error_Handler(); } if (HAL_TIM_IC_Init(&htim14) != HAL_OK) { Error_Handler(); } if (HAL_TIM_OnePulse_Init(&htim14, TIM_OPMODE_SINGLE) != HAL_OK) { Error_Handler(); } sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_RISING; sConfigIC.ICSelection = TIM_ICSELECTION_DIRECTTI; sConfigIC.ICPrescaler = TIM_ICPSC_DIV1; sConfigIC.ICFilter = 0; if (HAL_TIM_IC_ConfigChannel(&htim14, &sConfigIC, TIM_CHANNEL_1) != HAL_OK) { Error_Handler(); } if (HAL_TIMEx_RemapConfig(&htim14, TIM_TIM14_MCO) != HAL_OK) { Error_Handler(); } } TimHandle.Instance = TIMx; TimHandle.Init.Prescaler = uhPrescalerValue; TimHandle.Init.Period = PERIOD_VALUE; TimHandle.Init.ClockDivision = 0; TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP; TimHandle.Init.RepetitionCounter = 0; if (HAL_TIM_PWM_Init(&TimHandle) != HAL_OK) /* Common pwm configuration for TIM channel 1 */ sConfig.OCMode = TIM_OCMODE_PWM1; sConfig.OCPolarity = TIM_OCPOLARITY_HIGH; sConfig.OCFastMode = TIM_OCFAST_DISABLE; sConfig.OCNPolarity = TIM_OCNPOLARITY_HIGH; sConfig.OCIdleState = TIM_OCIDLESTATE_RESET; sConfig.OCNIdleState = TIM_OCNIDLESTATE_RESET; /* Set the pulse value for channel 1 */ sConfig.Pulse = PULSE_VALUE; if (HAL_TIM_PWM_ConfigChannel(&TimHandle, &sConfig, TIM_CHANNEL_1) != HAL_OK) { /* Configuration Error */ Error_Handler(); } //Start PWM signals generation #######################################*/ /* Start channel 1 */ if (HAL_TIM_PWM_Start(&TimHandle, TIM_CHANNEL_1) != HAL_OK) { /* PWM Generation Error */ Error_Handler(); }