欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: STM32 CUBEMX-usart+led程序 學習的步伐繼續 [打印本頁]

作者: 柱子111    時間: 2019-5-14 15:00
標題: STM32 CUBEMX-usart+led程序 學習的步伐繼續
之前因為事情拉下了一段時間現在繼續跟上
使用軟件:stm32cubemx+mdk5
硬件平臺:stm32f407
接上一個帖子
見證自己一步步學習的步伐



單片機源程序如下:
  1. /* Includes ------------------------------------------------------------------*/
  2. #include "stm32f4xx_hal.h"
  3. #include "usart.h"
  4. #include "gpio.h"

  5. /* USER CODE BEGIN Includes */

  6. /* USER CODE END Includes */

  7. /* Private variables ---------------------------------------------------------*/

  8. /* USER CODE BEGIN PV */
  9. /* Private variables ---------------------------------------------------------*/

  10. /* USER CODE END PV */

  11. /* Private function prototypes -----------------------------------------------*/
  12. void SystemClock_Config(void);

  13. /* USER CODE BEGIN PFP */
  14. /* Private function prototypes -----------------------------------------------*/

  15. /* USER CODE END PFP */

  16. /* USER CODE BEGIN 0 */

  17. /* USER CODE END 0 */

  18. int main(void)
  19. {

  20.   /* USER CODE BEGIN 1 */
  21. uint8_t  tx_buf[]="USART TEST\r\n";
  22.   /* USER CODE END 1 */

  23.   /* MCU Configuration----------------------------------------------------------*/

  24.   /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  25.   HAL_Init();

  26.   /* Configure the system clock */
  27.   SystemClock_Config();

  28.   /* Initialize all configured peripherals */
  29.   MX_GPIO_Init();
  30.   MX_USART1_UART_Init();

  31.   /* USER CODE BEGIN 2 */

  32.   /* USER CODE END 2 */

  33.   /* Infinite loop */
  34.   /* USER CODE BEGIN WHILE */
  35.   while (1)
  36.   {
  37.   /* USER CODE END WHILE */

  38.   /* USER CODE BEGIN 3 */
  39.         HAL_UART_Transmit(&huart1,"Hello!\r\n",8,10);
  40.                 HAL_Delay(1000);
  41.                         HAL_UART_Transmit(&huart1,tx_buf,12,10);
  42.                 HAL_Delay(1000);
  43.                
  44.   }
  45.   /* USER CODE END 3 */

  46. }

  47. /** System Clock Configuration
  48. */
  49. void SystemClock_Config(void)
  50. {

  51.   RCC_OscInitTypeDef RCC_OscInitStruct;
  52.   RCC_ClkInitTypeDef RCC_ClkInitStruct;

  53.   __HAL_RCC_PWR_CLK_ENABLE();

  54.   __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

  55.   RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  56.   RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  57.   RCC_OscInitStruct.HSICalibrationValue = 16;
  58.   RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  59.   HAL_RCC_OscConfig(&RCC_OscInitStruct);

  60.   RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  61.                               |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  62.   RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
  63.   RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  64.   RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  65.   RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  66.   HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0);

  67.   HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

  68.   HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

  69.   /* SysTick_IRQn interrupt configuration */
  70.   HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
  71. }

  72. /* USER CODE BEGIN 4 */

  73. /* USER CODE END 4 */

  74. #ifdef USE_FULL_ASSERT

  75. /**
  76.    * @brief Reports the name of the source file and the source line number
  77.    * where the assert_param error has occurred.
  78.    * @param file: pointer to the source file name
  79.    * @param line: assert_param error line source number
  80.    * @retval None
  81.    */
  82. void assert_failed(uint8_t* file, uint32_t line)
  83. {
  84.   /* USER CODE BEGIN 6 */
  85.   /* User can add his own implementation to report the file name and line number,
  86.     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  87.   /* USER CODE END 6 */

  88. }

  89. #endif

  90. /**
  91.   * @}
  92.   */

  93. /**
  94.   * @}
  95. */

  96. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
復制代碼

所有資料51hei提供下載:
USART.7z (287.45 KB, 下載次數: 12)







歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1