標(biāo)題:
STM32F4 HAL_PWM測頻程序
[打印本頁]
作者:
zlkj
時間:
2024-10-8 16:09
標(biāo)題:
STM32F4 HAL_PWM測頻程序
int main(void)
{
/* USER CODE BEGIN 1 */
uint8_t i=1;
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART3_UART_Init();
MX_USB_OTG_FS_PCD_Init();
MX_TIM10_Init();
MX_TIM2_Init();
/* USER CODE BEGIN 2 */
HAL_UART_Receive_IT(&huart3,&rxbuf,1);
HAL_TIM_PWM_Start(&htim10,TIM_CHANNEL_1);
HAL_TIM_IC_Start_IT(&htim2,TIM_CHANNEL_1);
HAL_TIM_IC_Start_IT(&htim2,TIM_CHANNEL_2);
// PWM_ChangeDuty(20);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
PWM_ChangeDuty(i);
HAL_Delay(100);
// PWM_ChangeDutyTest();
printf("PWM_Freq is %.4f\n",Freq_Capture);
printf("PWM_Duty is %.4f\n",PWM_Duty);
i++;
if(i>99)
{
i=1;
}
}
/* USER CODE END 3 */
}
復(fù)制代碼
原理圖: 無
仿真: 無
代碼:
STM32F4_PWM.7z
(318.59 KB, 下載次數(shù): 7)
2024-10-9 02:09 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1