Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Teensy 4.x support, add hardware PWM for Laser / Spindle / FAST_PWM_FAN #27608

Open
wants to merge 4 commits into
base: bugfix-2.1.x
Choose a base branch
from

Conversation

phizev
Copy link

@phizev phizev commented Dec 26, 2024

Description

This is an attempt at providing more complete support for Teensy 4.x boards, this includes:

  • Additional sanity checks.
  • Working freeMemory() function.
  • Hardware PWM / FAST_PWM_FAN / SPINDLE_FEATURE / LASER_FEATURE support.

Requirements

  • Teensy 4.x based board.

Benefits

  • Allows use of SPINDLE_FEATURE / LASER_FEATURE.
  • Allows use of FAST_PWM_FAN.
  • Working freeMemory() function.
  • Increased build time checks.

Configurations

#define MOTHERBOARD BOARD_TEENSY41

For checks:

  • #define SERIAL_STATS_MAX_RX_QUEUED (Or other SERIAL_STATS_*)
  • #define M100_FREE_MEMORY_WATCHER
  • #define BAUD_RATE_GCODE and #define SERIAL_PORT_2 -2

For hardware PWM:

  • #define FAST_PWM_FAN

Laser / Spindle:

  • #define SPINDLE_FEATURE
  • #define LASER_FEATURE
  • #define SPINDLE_LASER_USE_PWM

Working freeMemory() function

  • Just check free memory on serial during printer start.

Related Issues

[FR] LASER / SPINDLE pwm control on teensy 4.1

Notes on freeMemory() and Teensy 4.x memory layout

Regarding freeMemory(), it reports memory free for it's second RAM region used for malloc(), from https://forum.pjrc.com/index.php?threads/how-to-display-free-ram.33443/#post-275506

... the code in msg #6 will tell you the portion of RAM2 which is still unused by malloc() & C++ new.

One way Teensy 4.x differs from earlier Teensy and many other microcontrollers is the local variables are in a physically different memory than the heap for malloc().

(More recent versions of the Platform.io teensy platform make this arrangement clearer in the build summary, though updating that is going to be a follow up PR if I find a workable solution for changes to the SD library dependency other than just including the old library via #lib_deps.)

@phizev phizev marked this pull request as ready for review December 28, 2024 23:47
@phizev phizev changed the title Improve Teensy 4.x support Improve Teensy 4.x support, add hardware PWM for Laser / Spindle / FAST_PWM_FAN Dec 29, 2024
@thisiskeithb thisiskeithb linked an issue Dec 29, 2024 that may be closed by this pull request
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.

[FR] LASER / SPINDLE pwm control on teensy 4.1
1 participant