请教各位,使用stm32f407VET6 用的TIM1 脉冲输入引脚为PA11(TIM1_CH4),目前已实现中断读取CC4的数值,因为中断太频繁想改用DMA获取的方法,不知道怎么操作? TIM_HandleTypeDef TIM_PWMINPUT_Handle; DMA_HandleTypeDef TIM_DMA_Handle; uint32_t IC4_value[2]; //定时器配置 static void TIM_PWMINPUT_Config(void) { TIM_IC_InitTypeDef TIM_ICInitStructure; TIM_SlaveConfigTypeDef TIM_SlaveConfigStructure; __TIM1_CLK_ENABLE(); TIM_PWMINPUT_Handle.Instance = TIM1; TIM_PWMINPUT_Handle.Init.Period = 0xFFFF; // 高级控制定时器时钟源 TIMxCLK = HCLK=168MHz // 设定定时器频率为=TIMxCLK/(TIM_Prescaler+1)=1MHz TIM_PWMINPUT_Handle.Init.Prescaler = 168 - 1; TIM_PWMINPUT_Handle.Init.ClockDivision = 0; TIM_PWMINPUT_Handle.Init.CounterMode = TIM_COUNTERMODE_UP; HAL_TIM_IC_Init(&TIM_PWMINPUT_Handle); TIM_ICInitStructure.ICPolarity = TIM_ICPOLARITY_RISING; TIM_ICInitStructure.ICSelection = TIM_ICSELECTION_DIRECTTI; TIM_ICInitStructure.ICPrescaler = TIM_ICPSC_DIV1; TIM_ICInitStructure.ICFilter = 0x0; HAL_TIM_IC_ConfigChannel(&TIM_PWMINPUT_Handle, &TIM_ICInitStructure, TIM_CHANNEL_4); // HAL_TIM_IC_Start_IT(&TIM_PWMINPUT_Handle, TIM_CHANNEL_4); } //DMA配置 void tim_dma_config(void) { __DMA2_CLK_ENABLE(); TIM_DMA_Handle.Instance = DMA2_Stream4; TIM_DMA_Handle.Init.Channel = DMA_CHANNEL_6; TIM_DMA_Handle.Init.Direction = DMA_PERIPH_TO_MEMORY; TIM_DMA_Handle.Init.PeriphInc = DMA_PINC_DISABLE; TIM_DMA_Handle.Init.MemInc = DMA_MINC_ENABLE; TIM_DMA_Handle.Init.PeriphDataAlignment = DMA_MDATAALIGN_WORD; TIM_DMA_Handle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; TIM_DMA_Handle.Init.Mode = DMA_CIRCULAR; TIM_DMA_Handle.Init.Priority = DMA_PRIORITY_MEDIUM; TIM_DMA_Handle.Init.FIFOMode = DMA_FIFOMODE_DISABLE; TIM_DMA_Handle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; TIM_DMA_Handle.Init.MemBurst = DMA_MBURST_SINGLE; TIM_DMA_Handle.Init.PeriphBurst = DMA_PBURST_SINGLE; __HAL_LINKDMA(&TIM_PWMINPUT_Handle,hdma[TIM_DMA_ID_CC4], TIM_DMA_Handle); HAL_DMA_Init(TIM_PWMINPUT_Handle.hdma[TIM_DMA_ID_CC4]); HAL_TIM_IC_Start_DMA(&TIM_PWMINPUT_Handle,TIM_CHANNEL_4,&IC4_value,4); // HAL_NVIC_EnableIRQ(DMA2_Stream4_IRQn); } 接下来,在主函数不断读取IC4_value的值明显不对。请教大家有没有错 |
自己顶,求大神解惑 |
建议使用CubeMX配置 |
IIS3DHHCTR,这个料 温度从寄存器读取出来之后,把读取的数值转换成实际温度,有没有公式?
L9663如何使用上行缓冲区发送同步脉冲
STM32H750的AD采样问题
加速度计非线性度参数
LSM6DSR是左手坐标系吗?
比LIS3DH更稳定的超低功耗加速度计有哪些可选择?
LSM6DS3TR-C使用时工作电流比datasheet上大很多可能是什么原因?
lsm6dsl的sensor hub驱动LIS2MDL问题
求一款3轴MEMS加速度计,超低功耗,可唤醒发中断信号的芯片
stm32h503的i3c读写lsm6dso失败问题咨询