Marlin: [FR] Get SPEAKER working on SKR Mini E3 boards

Created on 5 Jun 2020  Â·  6Comments  Â·  Source: MarlinFirmware/Marlin

Description

Due to timer conflicts/lack of available timers, SPEAKER can’t be enabled on a couple of the SKR Mini E3 boards. This Feature Request is a continuation of comments from https://github.com/MarlinFirmware/Marlin/pull/18011.

STM32 Feature Request

Most helpful comment

The limited timers and inefficiency with which they are used by Arduino-based firmware causes a shortage of timers when using all the possible features on these boards.

For example, on the SKR Mini E3 boards they are allocated as below:

1 - Used for Fan PWM
2 - Temperature ISR
3 - Disabled because its pins are used by the SD slot. This might not truly be necessary, but it is what happens today.
4 - Software Serial (Needed for Mini E3 1.2 and E3 DIP boards)
5 - Step ISR
6 - Basic Timer (Currently unusable)
7 - Basic Timer (Unusable by most libraries, but might be used by _something_
8 - Servo / BLTouch

This accounts for every timer on a STM32F103 MPU. As can be seen, there is nothing left for the TONE_TIMER needed by the SPEAKER feature, unless we can use the Basic Timers.

Tone, Servo, and the Marlin ISRs are not written to work with a basic timer. SoftwareSerialM _might_ work on timer 6, but I have not yet tried it.

I have changes in progress which allow moving the temperature ISR to timer 6, freeing up timer 2. I have been unable to use Timer 7. Attempting to use it fails. I suspect it is being used by something already, but I do not know what.

All 6 comments

The limited timers and inefficiency with which they are used by Arduino-based firmware causes a shortage of timers when using all the possible features on these boards.

For example, on the SKR Mini E3 boards they are allocated as below:

1 - Used for Fan PWM
2 - Temperature ISR
3 - Disabled because its pins are used by the SD slot. This might not truly be necessary, but it is what happens today.
4 - Software Serial (Needed for Mini E3 1.2 and E3 DIP boards)
5 - Step ISR
6 - Basic Timer (Currently unusable)
7 - Basic Timer (Unusable by most libraries, but might be used by _something_
8 - Servo / BLTouch

This accounts for every timer on a STM32F103 MPU. As can be seen, there is nothing left for the TONE_TIMER needed by the SPEAKER feature, unless we can use the Basic Timers.

Tone, Servo, and the Marlin ISRs are not written to work with a basic timer. SoftwareSerialM _might_ work on timer 6, but I have not yet tried it.

I have changes in progress which allow moving the temperature ISR to timer 6, freeing up timer 2. I have been unable to use Timer 7. Attempting to use it fails. I suspect it is being used by something already, but I do not know what.

Something similar to STM32GENERIC's PWM would work - a single timer provides PWM -

https://github.com/huaweiwx/STM32GENERIC/blob/master/STM32/cores/arduino/stm32/stm32_PWM.c

I had all this working and figured out some timer conflict detection mechanisms and everything, but it kind of fell apart once I started trying to make it general enough to apply to all STM32F1 boards.

I'm having to remove that conflict detection logic (for now), due to the complications involved in knowing which timers will be used for TONE and FANs. Even if you specify TONE_TIMER in the platformio.ini file, the Maple tone.cpp library will auto-select a different timer if the pin aligns with a timer channel.

In light of the information thinkyhead added to this PR regarding the removal of Maple support in PlatformIO, it may be more valuable to focus on moving these boards to HAL/STM32, rather than investing in any improvements in HAL/STM32F1.
https://github.com/MarlinFirmware/Marlin/pull/17970#issuecomment-640299776

@xC0000005 how is your timer auto-select code developing for HAL/STM32? Is that something you anticipate contributing any time soon/

Yes, timer select is working. I have a few bugs to shake out and time’s hard to come by during the week, but it’s reasonable. I really also think I’m going to try and retrofit STM32GENERIC’s PWM method into Marlin, going through a PWM class. One timer for PWM IOs seems like a decent trade.

On Jun 7, 2020, at 10:09 PM, Jason Smith notifications@github.com wrote:

@xC0000005 https://github.com/xC0000005 how is your timer auto-select code developing for HAL/STM32? Is that something you anticipate contributing any time soon/

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/MarlinFirmware/Marlin/issues/18203#issuecomment-640370299, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHVGS4PO757X6KSOAK4LM43RVRW67ANCNFSM4NTHJT5Q.

I seriously need a cheat-sheet for all these timers and things, and which platforms and libraries are stealing them….

Was this page helpful?
0 / 5 - 0 ratings

Related issues

W8KDB picture W8KDB  Â·  4Comments

Ciev picture Ciev  Â·  3Comments

ahsnuet09 picture ahsnuet09  Â·  3Comments

jerryerry picture jerryerry  Â·  4Comments

spanner888 picture spanner888  Â·  4Comments