久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费
標題:
STM32L151 PWM輸出程序
[打印本頁]
作者:
zqqde
時間:
2020-1-3 15:42
標題:
STM32L151 PWM輸出程序
/* USER CODE BEGIN Header */
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "tim.h"
#include "usart.h"
#include "gpio.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "stdio.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
uint16_t dutyCycle = 0;
/* 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_TIM3_Init();
MX_USART1_UART_Init();
MX_TIM2_Init();
/* USER CODE BEGIN 2 */
// HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2);
HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2);
printf("test\r\n");
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
// while(dutyCycle < 1000)
// {
// dutyCycle++;
// __HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_2, dutyCycle);
// HAL_Delay(1);
// }
// while(dutyCycle)
// {
// dutyCycle--;
// __HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_2, dutyCycle);
// HAL_Delay(1);
// }
while(dutyCycle < 1000)
{
dutyCycle++;
__HAL_TIM_SET_COMPARE(&htim2, TIM_CHANNEL_2, dutyCycle);
HAL_Delay(1);
}
while(dutyCycle)
{
dutyCycle--;
__HAL_TIM_SET_COMPARE(&htim2, TIM_CHANNEL_2, dutyCycle);
HAL_Delay(1);
}
}
/* USER CODE END 3 */
}
/**
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Configure the main internal regulator output voltage
*/
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/** Initializes the CPU, AHB and APB busses clocks
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
RCC_OscInitStruct.MSICalibrationValue = 0;
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_5;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB busses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
{
Error_Handler();
}
}
/* USER CODE BEGIN 4 */
/* USER CODE END 4 */
/**
* @brief This function is executed in case of error occurrence.
* @retval None
*/
void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
/* USER CODE END Error_Handler_Debug */
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
復(fù)制代碼
全部資料51hei下載地址:
stm32l151_pwm.7z
(248.05 KB, 下載次數(shù): 26)
2020-1-3 18:35 上傳
點擊文件名下載附件
PWM 輸出
下載積分: 黑幣 -5
歡迎光臨 (http://www.zg4o1577.cn/bbs/)
Powered by Discuz! X3.1
主站蜘蛛池模板:
亚洲一区不卡
|
三级国产三级在线
|
国产免费拔擦拔擦8x高清
|
亚洲精品区
|
99免费在线观看
|
久久久久1
|
亚洲第一视频网
|
国产一级视频
|
日日夜夜天天
|
色综合色综合网色综合
|
精品综合久久久
|
成人免费观看网站
|
日韩有码在线观看
|
97国产在线观看
|
99精品久久久久
|
欧美精品在线视频
|
国产欧美精品一区二区色综合朱莉
|
久久久久久久久久久成人
|
午夜精品久久久久久不卡欧美一级
|
91电影院
|
黄色网址在线免费观看
|
国产午夜精品一区二区三区四区
|
久久国产一区二区三区
|
99久久日韩精品免费热麻豆美女
|
特黄毛片
|
久久国
|
欧美久久一级特黄毛片
|
91精品观看
|
免费看a
|
国户精品久久久久久久久久久不卡
|
国产精品久久在线
|
亚洲精品一区在线
|
精品国产免费人成在线观看
|
九九精品在线
|
成人毛片在线观看
|
国产精久久久
|
久久国产精品免费一区二区三区
|
日韩1区
|
91精品国产乱码久久久久久久久
|
国产精品精品视频一区二区三区
|
日日操夜夜操天天操
|