[STM32U5] 【NUCLEO-U575ZI-Q测评】+点灯

[复制链接]
950|11
 楼主| 比神乐 发表于 2023-2-16 16:06 | 显示全部楼层 |阅读模式
板子到了,我下载了资料,看原理图,一边是STLINK,可是接上没反应。
工程里没有STLINK。我用JLINK的SW方式也下载不进去。
后来,我在ST官网上下载了一个编程软件
8.jpg
用STLINK可以下载。
先下载SDK里的点灯程序试一试,果然好使。
原理图:
3.jpg 4.jpg
PC7接的其实是黄灯,上面标的绿灯。
主程序代码:
  1. #include "main.h"

  2. /* Private includes ----------------------------------------------------------*/
  3. /* USER CODE BEGIN Includes */

  4. /* USER CODE END Includes */

  5. /* Private typedef -----------------------------------------------------------*/
  6. /* USER CODE BEGIN PTD */

  7. /* USER CODE END PTD */

  8. /* Private define ------------------------------------------------------------*/
  9. /* USER CODE BEGIN PD */

  10. /* USER CODE END PD */

  11. /* Private macro -------------------------------------------------------------*/
  12. /* USER CODE BEGIN PM */

  13. /* USER CODE END PM */

  14. /* Private variables ---------------------------------------------------------*/

  15. /* USER CODE BEGIN PV */
  16. static GPIO_InitTypeDef  GPIO_InitStruct;

  17. /* USER CODE END PV */

  18. /* Private function prototypes -----------------------------------------------*/
  19. void SystemClock_Config(void);
  20. static void SystemPower_Config(void);
  21. static void MX_ICACHE_Init(void);
  22. /* USER CODE BEGIN PFP */

  23. /* USER CODE END PFP */

  24. /* Private user code ---------------------------------------------------------*/
  25. /* USER CODE BEGIN 0 */

  26. /* USER CODE END 0 */

  27. /**
  28.   * [url=home.php?mod=space&uid=247401]@brief[/url]  The application entry point.
  29.   * @retval int
  30.   */
  31. int main(void)
  32. {
  33.   /* USER CODE BEGIN 1 */
  34.   /* STM32U5xx HAL library initialization:
  35.        - Configure the Flash prefetch
  36.        - Configure the Systick to generate an interrupt each 1 msec
  37.        - Set NVIC Group Priority to 3
  38.        - Low Level Initialization
  39.      */
  40.   /* USER CODE END 1 */

  41.   /* MCU Configuration--------------------------------------------------------*/

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

  44.   /* USER CODE BEGIN Init */

  45.   /* USER CODE END Init */

  46.   /* Configure the system clock */
  47.   SystemClock_Config();

  48.   /* Configure the System Power */
  49.   SystemPower_Config();

  50.   /* USER CODE BEGIN SysInit */

  51.   /* USER CODE END SysInit */

  52.   /* Initialize all configured peripherals */
  53.   MX_ICACHE_Init();
  54.   /* USER CODE BEGIN 2 */

  55.    /* -1- Enable GPIO Clock (to be able to program the configuration registers) */
  56.   LED1_GPIO_CLK_ENABLE();
  57.   LED2_GPIO_CLK_ENABLE();

  58.   /* -2- Configure IO in output push-pull mode to drive external LEDs */
  59.   GPIO_InitStruct.Mode  = GPIO_MODE_OUTPUT_PP;
  60.   GPIO_InitStruct.Pull  = GPIO_PULLUP;
  61.   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;

  62.   GPIO_InitStruct.Pin = LED1_PIN;
  63.   HAL_GPIO_Init(LED1_GPIO_PORT, &GPIO_InitStruct);
  64.   GPIO_InitStruct.Pin = LED2_PIN;
  65.   HAL_GPIO_Init(LED2_GPIO_PORT, &GPIO_InitStruct);

  66.   /* USER CODE END 2 */

  67.   /* Infinite loop */
  68.   /* USER CODE BEGIN WHILE */
  69.   while (1)
  70.   {
  71.     /* USER CODE END WHILE */

  72.     /* USER CODE BEGIN 3 */
  73.     HAL_GPIO_TogglePin(LED1_GPIO_PORT, LED1_PIN);
  74.     /* Insert delay 100 ms */
  75.     HAL_Delay(1000);
  76.     HAL_GPIO_TogglePin(LED2_GPIO_PORT, LED2_PIN);
  77.     /* Insert delay 100 ms */
  78.     HAL_Delay(1000);

  79.   }
  80.   /* USER CODE END 3 */
  81. }

  82. /**
  83.   * @brief System Clock Configuration
  84.   * @retval None
  85.   */
  86. void SystemClock_Config(void)
  87. {
  88.   RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  89.   RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

  90.   /** Configure the main internal regulator output voltage
  91.   */
  92.   if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
  93.   {
  94.     Error_Handler();
  95.   }

  96.   /** Initializes the CPU, AHB and APB busses clocks
  97.   */
  98.   RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
  99.   RCC_OscInitStruct.MSIState = RCC_MSI_ON;
  100.   RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
  101.   RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_4;
  102.   RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  103.   RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
  104.   RCC_OscInitStruct.PLL.PLLMBOOST = RCC_PLLMBOOST_DIV1;
  105.   RCC_OscInitStruct.PLL.PLLM = 1;
  106.   RCC_OscInitStruct.PLL.PLLN = 80;
  107.   RCC_OscInitStruct.PLL.PLLP = 2;
  108.   RCC_OscInitStruct.PLL.PLLQ = 2;
  109.   RCC_OscInitStruct.PLL.PLLR = 2;
  110.   RCC_OscInitStruct.PLL.PLLRGE = RCC_PLLVCIRANGE_0;
  111.   RCC_OscInitStruct.PLL.PLLFRACN = 0;
  112.   if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  113.   {
  114.     Error_Handler();
  115.   }

  116.   /** Initializes the CPU, AHB and APB busses clocks
  117.   */
  118.   RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  119.                               |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2
  120.                               |RCC_CLOCKTYPE_PCLK3;
  121.   RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  122.   RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  123.   RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  124.   RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  125.   RCC_ClkInitStruct.APB3CLKDivider = RCC_HCLK_DIV1;

  126.   if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
  127.   {
  128.     Error_Handler();
  129.   }
  130. }

  131. /**
  132.   * @brief Power Configuration
  133.   * @retval None
  134.   */
  135. static void SystemPower_Config(void)
  136. {

  137.   /*
  138.    * Disable the internal Pull-Up in Dead Battery pins of UCPD peripheral
  139.    */
  140.   HAL_PWREx_DisableUCPDDeadBattery();

  141.   /*
  142.    * Switch to SMPS regulator instead of LDO
  143.    */
  144.   if (HAL_PWREx_ConfigSupply(PWR_SMPS_SUPPLY) != HAL_OK)
  145.   {
  146.     Error_Handler();
  147.   }
  148. }

  149. /**
  150.   * @brief ICACHE Initialization Function
  151.   * @param None
  152.   * @retval None
  153.   */
  154. static void MX_ICACHE_Init(void)
  155. {

  156.   /* USER CODE BEGIN ICACHE_Init 0 */

  157.   /* USER CODE END ICACHE_Init 0 */

  158.   /* USER CODE BEGIN ICACHE_Init 1 */

  159.   /* USER CODE END ICACHE_Init 1 */

  160.   /** Enable instruction cache in 1-way (direct mapped cache)
  161.   */
  162.   if (HAL_ICACHE_ConfigAssociativityMode(ICACHE_1WAY) != HAL_OK)
  163.   {
  164.     Error_Handler();
  165.   }
  166.   if (HAL_ICACHE_Enable() != HAL_OK)
  167.   {
  168.     Error_Handler();
  169.   }
  170.   /* USER CODE BEGIN ICACHE_Init 2 */

  171.   /* USER CODE END ICACHE_Init 2 */

  172. }

  173. /* USER CODE BEGIN 4 */
  174. /* USER CODE END 4 */

  175. /**
  176.   * @brief  This function is executed in case of error occurrence.
  177.   * @retval None
  178.   */
  179. void Error_Handler(void)
  180. {
  181.   /* USER CODE BEGIN Error_Handler_Debug */
  182.   /* User can add his own implementation to report the HAL error return state */
  183.   while(1)
  184.   {
  185.   }
  186.   /* USER CODE END Error_Handler_Debug */
  187. }

  188. #ifdef  USE_FULL_ASSERT
  189. /**
  190.   * @brief  Reports the name of the source file and the source line number
  191.   *         where the assert_param error has occurred.
  192.   * @param  file: pointer to the source file name
  193.   * @param  line: assert_param error line source number
  194.   * @retval None
  195.   */
  196. void assert_failed(uint8_t *file, uint32_t line)
  197. {
  198.   /* USER CODE BEGIN 6 */
  199.   /* User can add his own implementation to report the file name and line number,
  200.     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  201.   /* Infinite loop */
  202.   while (1)
  203.   {
  204.   }

  205.   /* USER CODE END 6 */
  206. }
  207. #endif /* USE_FULL_ASSERT */
初始化代码:
  1. #define LED1_PIN                                GPIO_PIN_7
  2. #define LED1_GPIO_PORT                          GPIOC
  3. #define LED1_GPIO_CLK_ENABLE()                  __HAL_RCC_GPIOC_CLK_ENABLE()
  4. #define LED1_GPIO_CLK_DISABLE()                 __HAL_RCC_GPIOC_CLK_DISABLE()

  5. #define LED2_PIN                                GPIO_PIN_7
  6. #define LED2_GPIO_PORT                          GPIOB
  7. #define LED2_GPIO_CLK_ENABLE()                  __HAL_RCC_GPIOB_CLK_ENABLE()
  8. #define LED2_GPIO_CLK_DISABLE()                 __HAL_RCC_GPIOB_CLK_DISABLE()
烧写软件界面:
5.jpg
效果图:
9.jpg 10.jpg 11.jpg 12.jpg

ingramward 发表于 2023-3-7 22:06 | 显示全部楼层
STM32U575的运算能力还是非常强大的
lzmm 发表于 2023-3-11 20:30 | 显示全部楼层
STM32U5目前已经推出STM32U575、 STM32U585两个系列
qiufengsd 发表于 2023-3-18 14:41 | 显示全部楼层
STM32U575和STM32U585微控制器兼容的吗?
ingramward 发表于 2023-3-18 18:08 | 显示全部楼层
NUCLEO-U575ZI的价格怎么样
 楼主| 比神乐 发表于 2023-3-19 09:12 | 显示全部楼层
ingramward 发表于 2023-3-18 18:08
NUCLEO-U575ZI的价格怎么样

不知道,没买过
vivilyly 发表于 2023-3-22 10:51 | 显示全部楼层
这个板子是申请的吗?              
 楼主| 比神乐 发表于 2023-3-23 09:49 | 显示全部楼层
vivilyly 发表于 2023-3-22 10:51
这个板子是申请的吗?

我记得没申请啊,就发给我了
happy_10 发表于 2023-3-27 20:47 | 显示全部楼层
STM32U575和STM32U585微控制器兼容的吗?
 楼主| 比神乐 发表于 2023-3-28 09:37 | 显示全部楼层
happy_10 发表于 2023-3-27 20:47
STM32U575和STM32U585微控制器兼容的吗?

不清楚
您需要登录后才可以回帖 登录 | 注册

本版积分规则

470

主题

3537

帖子

7

粉丝
快速回复 在线客服 返回列表 返回顶部