From f2f136e0147b49c179ef9d4619334b2a0b79dbc1 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Wed, 24 Aug 2022 10:18:45 +0300 Subject: [PATCH] Use timer3 instead of timer5 on miniRambo --- Firmware/MarlinSerial.h | 5 ++-- Firmware/macros.h | 3 ++ Firmware/pins_Einsy_1_0.h | 3 ++ Firmware/pins_Rambo_1_0.h | 2 ++ Firmware/pins_Rambo_1_3.h | 2 ++ Firmware/temperature.cpp | 63 ++++++++++++++++++++++++++------------- 6 files changed, 55 insertions(+), 23 deletions(-) diff --git a/Firmware/MarlinSerial.h b/Firmware/MarlinSerial.h index 3bb0926b..61da2760 100644 --- a/Firmware/MarlinSerial.h +++ b/Firmware/MarlinSerial.h @@ -37,11 +37,10 @@ // These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor // requires two levels of indirection to expand macro values properly) -#define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) #if SERIAL_PORT == 0 && (!defined(UBRR0H) || !defined(UDR0)) // use un-numbered registers if necessary -#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##suffix +#define SERIAL_REGNAME(registerbase,number,suffix) _REGNAME_SHORT(registerbase, suffix) #else -#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix +#define SERIAL_REGNAME(registerbase,number,suffix) _REGNAME(registerbase, number, suffix) #endif // Registers used by MarlinSerial class (these are expanded diff --git a/Firmware/macros.h b/Firmware/macros.h index 95a737e1..aa282dd5 100644 --- a/Firmware/macros.h +++ b/Firmware/macros.h @@ -11,6 +11,9 @@ #define CRITICAL_SECTION_END SREG = _sreg; #endif //CRITICAL_SECTION_START +#define _REGNAME(registerbase,number,suffix) registerbase##number##suffix +#define _REGNAME_SHORT(registerbase,suffix) registerbase##suffix + // Macros to make a string from a macro #define STRINGIFY_(M) #M #define STRINGIFY(M) STRINGIFY_(M) diff --git a/Firmware/pins_Einsy_1_0.h b/Firmware/pins_Einsy_1_0.h index 3f73bdd9..d8c316b4 100755 --- a/Firmware/pins_Einsy_1_0.h +++ b/Firmware/pins_Einsy_1_0.h @@ -78,6 +78,9 @@ #define VOLT_IR_PIN 8 //A8 +#define TEMP_TIM 5 + + #define E0_TMC2130_CS 66 #define E0_TMC2130_DIAG 65 #define E0_STEP_PIN 34 diff --git a/Firmware/pins_Rambo_1_0.h b/Firmware/pins_Rambo_1_0.h index 5cd0a670..1bccd5c5 100644 --- a/Firmware/pins_Rambo_1_0.h +++ b/Firmware/pins_Rambo_1_0.h @@ -57,6 +57,8 @@ #define TEMP_PINDA_PIN 1 //A1 +#define TEMP_TIM 3 + #define E0_STEP_PIN 34 #define E0_DIR_PIN 43 diff --git a/Firmware/pins_Rambo_1_3.h b/Firmware/pins_Rambo_1_3.h index f733c105..c5f0e4c1 100644 --- a/Firmware/pins_Rambo_1_3.h +++ b/Firmware/pins_Rambo_1_3.h @@ -60,6 +60,8 @@ #define TEMP_PINDA_PIN 1 //A1 +#define TEMP_TIM 3 + #define E0_STEP_PIN 34 #define E0_DIR_PIN 43 diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 80356bd4..a96eb0f4 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -60,13 +60,36 @@ // temperature manager timer configuration #define TEMP_MGR_INTV 0.27 // seconds, ~3.7Hz -#define TIMER5_PRESCALE 256 -#define TIMER5_OCRA_OVF (uint16_t)(TEMP_MGR_INTV / ((long double)TIMER5_PRESCALE / F_CPU)) -#define TEMP_MGR_INT_FLAG_STATE() (TIFR5 & (1<