Skip to content

Commit

Permalink
PWM fixes, slow down fan update
Browse files Browse the repository at this point in the history
include LPC1768 syntax for M42

couple more pin_t changes

consistency

change M42 to R, P format

Revert "change M42 to R, P format"

This reverts commit 01f12f579ec9ccc1bb9126e68d2c86449e9b7edf.
  • Loading branch information
Bob-the-Kuhn authored and thinkyhead committed Nov 18, 2017
1 parent 60adc6f commit c140007
Show file tree
Hide file tree
Showing 7 changed files with 354 additions and 347 deletions.
596 changes: 307 additions & 289 deletions Marlin/src/HAL/HAL_LPC1768/LPC1768_PWM.cpp

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions Marlin/src/HAL/HAL_LPC1768/LPC1768_PWM.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@
#define MR0_MARGIN 200 // if channel value too close to MR0 the system locks up

void LPC1768_PWM_init(void);
bool LPC1768_PWM_attach_pin(pin_t pin, uint32_t min = 1, uint32_t max = (LPC_PWM1_MR0 - MR0_MARGIN), uint8_t servo_index = 0xff);
void LPC1768_PWM_update_map_MR(void);
void LPC1768_PWM_update(void);
bool LPC1768_PWM_attach_pin(pin_t pin, uint32_t min=1, uint32_t max=(LPC_PWM1_MR0 - (MR0_MARGIN)), uint8_t servo_index=0xFF);
bool LPC1768_PWM_write(pin_t pin, uint32_t value);
bool LPC1768_PWM_detach_pin(pin_t pin);
bool useable_hardware_PWM(pin_t pin);
2 changes: 1 addition & 1 deletion Marlin/src/HAL/HAL_LPC1768/fastio.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include "arduino.h"
#include "pinmapping.h"

bool useable_hardware_PWM(uint8_t pin);
bool useable_hardware_PWM(pin_t pin);
#define USEABLE_HARDWARE_PWM(pin) useable_hardware_PWM(pin)

#define LPC_PORT_OFFSET (0x0020)
Expand Down
7 changes: 6 additions & 1 deletion Marlin/src/Marlin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,12 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
tmc2130_checkOverTemp();
#endif

planner.check_axes_activity();
// Limit check_axes_activity frequency to 10Hz
static millis_t next_check_axes_ms = 0;
if (ELAPSED(ms, next_check_axes_ms)) {
planner.check_axes_activity();
next_check_axes_ms = ms + 100UL;
}
}

/**
Expand Down
5 changes: 5 additions & 0 deletions Marlin/src/gcode/control/M42.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
* M42: Change pin status via GCode
*
* P<pin> Pin number (LED if omitted)
* For LPC1768 use M42 P1.20 S255 if wanting to set P1_20 to logic 1
* NOTE - Repetier Host truncates trailing zeros on a decimal when
* sending commands so typing M42 P1.20 S255 results in
* M42 P1.2 S255 being sent. Pronterface doesn't have this issue.
*
* S<byte> Pin status from 0 - 255
*/
void GcodeSuite::M42() {
Expand Down
83 changes: 32 additions & 51 deletions Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1271,57 +1271,38 @@ void Temperature::init() {

#if ENABLED(FAST_PWM_FAN)

void Temperature::setPwmFrequency(const uint8_t pin, int val) {
val &= 0x07;
switch (digitalPinToTimer(pin)) {
#ifdef TCCR0A
#if !AVR_AT90USB1286_FAMILY
case TIMER0A:
void Temperature::setPwmFrequency(const pin_t pin, int val) {
#ifdef ARDUINO
val &= 0x07;
switch (digitalPinToTimer(pin)) {
#ifdef TCCR0A
#if !AVR_AT90USB1286_FAMILY
case TIMER0A:
#endif
case TIMER0B: //_SET_CS(0, val);
break;
#endif
case TIMER0B:
//_SET_CS(0, val);
break;
#endif
#ifdef TCCR1A
case TIMER1A:
case TIMER1B:
//_SET_CS(1, val);
break;
#endif
#ifdef TCCR2
case TIMER2:
case TIMER2:
_SET_CS(2, val);
break;
#endif
#ifdef TCCR2A
case TIMER2A:
case TIMER2B:
_SET_CS(2, val);
break;
#endif
#ifdef TCCR3A
case TIMER3A:
case TIMER3B:
case TIMER3C:
_SET_CS(3, val);
break;
#endif
#ifdef TCCR4A
case TIMER4A:
case TIMER4B:
case TIMER4C:
_SET_CS(4, val);
break;
#endif
#ifdef TCCR5A
case TIMER5A:
case TIMER5B:
case TIMER5C:
_SET_CS(5, val);
break;
#endif
}
#ifdef TCCR1A
case TIMER1A: case TIMER1B: //_SET_CS(1, val);
break;
#endif
#ifdef TCCR2
case TIMER2: case TIMER2: _SET_CS(2, val); break;
#endif
#ifdef TCCR2A
case TIMER2A: case TIMER2B: _SET_CS(2, val); break;
#endif
#ifdef TCCR3A
case TIMER3A: case TIMER3B: case TIMER3C: _SET_CS(3, val); break;
#endif
#ifdef TCCR4A
case TIMER4A: case TIMER4B: case TIMER4C: _SET_CS(4, val); break;
#endif
#ifdef TCCR5A
case TIMER5A: case TIMER5B: case TIMER5C: _SET_CS(5, val); break;
#endif
}
#endif
}

#endif // FAST_PWM_FAN
Expand All @@ -1332,7 +1313,7 @@ void Temperature::init() {
* their target temperature by a configurable margin.
* This is called when the temperature is set. (M104, M109)
*/
void Temperature::start_watching_heater(uint8_t e) {
void Temperature::start_watching_heater(const uint8_t e) {
#if HOTENDS == 1
UNUSED(e);
#endif
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/module/temperature.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,14 @@ class Temperature {
static int16_t degTargetBed() { return target_temperature_bed; }

#if WATCH_HOTENDS
static void start_watching_heater(uint8_t e = 0);
static void start_watching_heater(const uint8_t e = 0);
#endif

#if WATCH_THE_BED
static void start_watching_bed();
#endif

static void setTargetHotend(const int16_t celsius, uint8_t e) {
static void setTargetHotend(const int16_t celsius, const uint8_t e) {
#if HOTENDS == 1
UNUSED(e);
#endif
Expand Down

0 comments on commit c140007

Please sign in to comment.