2017-04-25 01:00 PM
Hello. Stm32f407VGt6 (STM32F4Discovery) Cube Sw4stm32 The function 'Input capture' on stm32f407vgt6 does not work. The interrupt program does not work. In this case, if download the same program in stm32f103vet6, then everything works. What is the problem?
* File Name : main.c
*/
/* Includes ------------------------------------------------------------------*/#include 'main.h'#include 'stm32f4xx_hal.h'#include 'dma.h'#include 'tim.h'#include 'gpio.h'/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/uint16_t i;uint8_t j=1;uint16_t buf[3905];uint16_t bufprom[3905];uint8_t m=1, start=0;uint16_t led_green_full[24]={25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25};uint16_t led_red_full[24]={16,16,16,16,16,16,16,16,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8};uint16_t led_blue_full[24]={8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,16,16,16,16,16,16,16,16};uint16_t *pled_red_full=led_red_full;
uint16_t *pled_blue_full=led_blue_full;uint16_t *pbuf=buf;uint16_t count;float delay_led;/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);void Error_Handler(void);static void MX_NVIC_Init(void);/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*//* USER CODE END PFP */
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
int main(void)
{/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();/* Configure the system clock */
SystemClock_Config();/* Initialize all configured peripherals */
MX_GPIO_Init(); MX_DMA_Init(); MX_TIM4_Init(); MX_TIM2_Init(); HAL_TIM_PWM_Start_DMA(&htim4, TIM_CHANNEL_1, (uint32_t *)buf,3905); HAL_TIM_IC_Start_IT(&htim2, TIM_CHANNEL_1); HAL_TIM_IC_Start_IT(&htim2, TIM_CHANNEL_2);/* Initialize interrupts */
MX_NVIC_Init();* @file stm32f4xx_it.c
****************************************************************************** *//* Includes ------------------------------------------------------------------*/#include 'stm32f4xx_hal.h'#include 'stm32f4xx.h'#include 'stm32f4xx_it.h'/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/* External variables --------------------------------------------------------*/
extern DMA_HandleTypeDef hdma_tim4_ch1;extern TIM_HandleTypeDef htim2;uint16_t period, capture_1, capture_2;extern float delay_led;uint8_t n = 0x00;extern uint8_t m;void TIM2_IRQHandler(void)
{ /* USER CODE BEGIN TIM2_IRQn 0 *//* USER CODE END TIM2_IRQn 0 */
HAL_TIM_IRQHandler(&htim2); /* USER CODE BEGIN TIM2_IRQn 1 */ if(!n) { capture_1 = TIM2->CCR1; n = ~n; } else { capture_2 = TIM2->CCR2; period = capture_2 - capture_1; delay_led=period*0.02; m=3;n = ~n;
}/* USER CODE END TIM2_IRQn 1 */
}