Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Added support for STM32F412Zx MCU#2011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fpistm merged 2 commits intostm32duino:mainfromToritos01:main
May 16, 2023
Merged

Conversation

Toritos01
Copy link

@Toritos01Toritos01 commentedApr 26, 2023
edited
Loading

This PR fixes/implements generic support for the STM32F412Zx variant, using the steps at this link:https://github.com/stm32duino/Arduino_Core_STM32/wiki/Add-a-new-variant-%28board%29

The motivation for stm32duino to have support for more variants, and to allow me to use this repo with a board that I personally have.

@fpistmfpistm added this to the2.6.0 milestoneApr 26, 2023
@fpistmfpistm added the new variantAdd support of new bard labelApr 26, 2023
Copy link
Member

@fpistmfpistm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Some minor changes to be done.
Is USB clock configured to 48MHz?

@Toritos01
Copy link
Author

Some minor changes to be done. Is USB clock configured to 48MHz?

I tried enabling UST_OTG_FS on STM32CubeMx, but doing so breaks the clock configuration

Copy link
Member

@fpistmfpistm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks for the update.
One line to remove and a proposal for system core clock config to have USB clokk at 48Mhz.
If you can test it and give your feedback, I could not test as I do not have a STM32F412Zx board.

@Toritos01
Copy link
Author

Sorry for the delay with testing this, didn't have access to my STM32F4 for a few days. I tested out the proposed fixes, but when I try running the CheckVariant.ino program, my LED does not blink and nothing shows up the serial monitor. Any recommendations on additional steps to take for this to work?

@fpistm
Copy link
Member

Hi@Toritos01
No worry.
The main changes was to configure clock for the USB:

+  RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {};    /** Configure the main internal regulator output voltage  */   __HAL_RCC_PWR_CLK_ENABLE();   __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);    /** Initializes the RCC Oscillators according to the specified parameters  * in the RCC_OscInitTypeDef structure.  */   RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;   RCC_OscInitStruct.HSIState = RCC_HSI_ON;   RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;   RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;   RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;   RCC_OscInitStruct.PLL.PLLM = 8;-  RCC_OscInitStruct.PLL.PLLN = 100;+  RCC_OscInitStruct.PLL.PLLN = 96;   RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;-  RCC_OscInitStruct.PLL.PLLQ = 2;+  RCC_OscInitStruct.PLL.PLLQ = 4;   RCC_OscInitStruct.PLL.PLLR = 2;   if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {     Error_Handler();   }    /** Initializes the CPU, AHB and APB buses clocks-   */-  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;+  */+  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK+                                | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;   RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;   RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;   RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;@@ -58,6 +59,14 @@ WEAK void SystemClock_Config(void)   if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK) {     Error_Handler();   }++  /** Initializes the peripherals clock+  */+  PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_CLK48;+  PeriphClkInitStruct.Clk48ClockSelection = RCC_CLK48CLKSOURCE_PLLQ;+  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {+    Error_Handler();+  }

It was generated thanks CubeMx and should be fine.
Main changes is we change the clock freq from 100 to 96 MHz in order to have a 48MHz for USB.
That's strange it does not works. I guess it fails in theHAL_RCCEx_PeriphCLKConfig but don't know why. You could try to debug with Arduino IDE 2.1.0 by enabling the -Og and -g in the menu. Then you should be able to debug.

Toritos01and others added2 commitsMay 16, 2023 10:02
Signed-off-by: Brandon Diaz <bld68@cornell.edu>
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
@fpistm
Copy link
Member

Hi@Toritos01
I've been able to test with a Nucelo F412ZG. I've simplify the clock config and tested the generic and it works with or without USB.
I've also added the Nucelo F412ZG variant.

Toritos01 reacted with thumbs up emoji

@fpistmfpistm linked an issueMay 16, 2023 that may beclosed by this pull request
@fpistm
Copy link
Member

Fixes#1899

@fpistmfpistm merged commit5c7107b intostm32duino:mainMay 16, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@fpistmfpistmfpistm approved these changes

Assignees
No one assigned
Labels
new variantAdd support of new bard
Projects
None yet
Milestone
2.6.0
Development

Successfully merging this pull request may close these issues.

Stm32f412zg support
2 participants
@Toritos01@fpistm

[8]ページ先頭

©2009-2025 Movatter.jp