Skip to content

Conversation

@mh-dm
Copy link
Contributor

@mh-dm mh-dm commented Jun 7, 2024

Set cpu frequency based on F_CPU / platformio board_build.f_cpu. Fixes the potential pitfall where someone might try using board_build.f_cpu resulting in an F_CPU that differs from the one actually configured (through LPC_SC->PLL0CFG). F_CPU is used in system/lpc176x/time.h for the delay* functions and is also widely used in projects like Marlin.

Only allows 120mhz on MCU_LPC1769 and only the most commonly configured frequencies.

@mh-dm mh-dm force-pushed the F_CPU branch 2 times, most recently from 7650df6 to cf1104e Compare June 7, 2024 15:41
@mh-dm mh-dm changed the title Allow configuring cpu frequency through board_build.f_cpu Set cpu frequency based on F_CPU / board_build.f_cpu Nov 10, 2024
@mh-dm
Copy link
Contributor Author

mh-dm commented Nov 10, 2024

Comments welcome, including on whether I should remove the 96mhz option.

@p3p
Copy link
Owner

p3p commented Nov 30, 2024

I'm reluctant to merge this without the runtime check for LPC1769 to avoid Marlin users overclocking LPC1768 boards accidentally

@mh-dm
Copy link
Contributor Author

mh-dm commented Nov 30, 2024

The check in #elif F_CPU == 120000000 && MCU_LPC1769 works to prevent an accidental overclock. Or are you talking about a scenario where Marlin users accidentally configure for an LPC1769 board when actually using an LPC1768 board?

@p3p
Copy link
Owner

p3p commented Nov 30, 2024

indeed, there is no check at flash time (via sdcard) that the mcu is what the binary was built for, the original isLPC1769() does it at runtime which will make sure the clock is correct at the cost of the bad timing constant.

@mh-dm
Copy link
Contributor Author

mh-dm commented Dec 9, 2024

Good news then: Marlin has checks to make sure the selected architecture incl. the microcontroller matches the board. Example that I just tried:
Error: Build environment 'LPC1769' is incompatible with BOARD_BTT_SKR_V1_3. Use one of these environments: LPC1768

This prevents an accidental overclock like from setting default_envs = LPC1769 (which sets MCU_1769) in platform.ini but when actually using a 1768 board.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants