- 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 */
- }
復制代碼
原理圖: 無
仿真: 無
代碼:
STM32F4_PWM.7z
(318.59 KB, 下載次數: 7)
2024-10-9 02:09 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|