Skip to content

F_CPU define not picked up correctly in Arduino IDE #3098

Closed

Description

@TMRh20

Describe the bug
Attempting to use F_CPU for device detection doesn't work. It seems that F_CPU is actually defined later in the build process, so cannot be picked up properly using defines.

To Reproduce

#if defined F_CPU
  #if F_CPU >= 45000000
    #define bufferSize 1000
  #else
    #define bufferSize 100
  #endif

#else
  #define bufferSize 500
#endif

void setup() {
    Serial.begin(115200);
}

void loop() {
  Serial.print("Buffer Size: ");
  Serial.println(bufferSize);
  Serial.print("F_CPU: ");
  Serial.println(F_CPU);
  delay(1000);
}

Steps to reproduce the behavior:

  1. Run the included example code
  2. See F_CPU is displayed as 96MHz, although the selected buffer size is the smallest (detected at <45Mhz)

Expected behavior
Expected F_CPU to actually detect the configured clock speed, and allow configuration of buffer sizes based on CPU speed.

Desktop (please complete the following information):

  • OS: Windows 11
  • Arduino IDE version: 2.3.10
  • STM32 core version: 3.0.0
  • Tools menu settings if not the default: Any
  • Upload method: DFU

Board (please complete the following information):

  • Name: Black Pill STM32F411CEU6
  • Hardware Revision: n/a
  • Extra hardware used if any: none required

Additional context
See nRF24/RF24Network#278
nRF24/RF24Network#277

Activity

  1. locked and limited conversation to collaborators on Oct 17, 2026
  2. converted this issue into a discussion #3099 on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions