Cleaner transitions when using VVT for on/off control
This commit is contained in:
parent
1da217eb40
commit
bfc5c7c841
|
@ -6,6 +6,18 @@ void boostControl();
|
|||
void vvtControl();
|
||||
void initialiseFan();
|
||||
|
||||
#if defined(CORE_AVR)
|
||||
#define ENABLE_BOOST_TIMER() TIMSK1 |= (1 << OCIE1A)
|
||||
#define DISABLE_BOOST_TIMER() TIMSK1 &= ~(1 << OCIE1A)
|
||||
#define ENABLE_VVT_TIMER() TIMSK1 |= (1 << OCIE1B)
|
||||
#define DISABLE_VVT_TIMER() TIMSK1 &= ~(1 << OCIE1B)
|
||||
|
||||
#define BOOST_PIN_LOW() *boost_pin_port &= ~(boost_pin_mask)
|
||||
#define BOOST_PIN_HIGH() *boost_pin_port |= (boost_pin_mask)
|
||||
#define VVT_PIN_LOW() *vvt_pin_port &= ~(vvt_pin_mask)
|
||||
#define VVT_PIN_HIGH() *vvt_pin_port |= (vvt_pin_mask)
|
||||
#endif
|
||||
|
||||
volatile byte *boost_pin_port;
|
||||
volatile byte boost_pin_mask;
|
||||
volatile byte *vvt_pin_port;
|
||||
|
|
|
@ -106,11 +106,25 @@ void vvtControl()
|
|||
if( configPage3.vvtEnabled == 1 )
|
||||
{
|
||||
byte vvtDuty = get3DTableValue(&vvtTable, currentStatus.TPS, currentStatus.RPM);
|
||||
vvt_pwm_target_value = percentage(vvtDuty, vvt_pwm_max_count);
|
||||
if(vvtDuty == 0)
|
||||
{
|
||||
//Make sure solenoid is off (0% duty)
|
||||
VVT_PIN_LOW();
|
||||
DISABLE_VVT_TIMER();
|
||||
}
|
||||
else if (vvtDuty >= 100)
|
||||
{
|
||||
//Make sure solenoid is on (100% duty)
|
||||
VVT_PIN_HIGH();
|
||||
DISABLE_VVT_TIMER();
|
||||
}
|
||||
else
|
||||
{
|
||||
vvt_pwm_target_value = percentage(vvtDuty, vvt_pwm_max_count);
|
||||
ENABLE_VVT_TIMER();
|
||||
}
|
||||
}
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||
else { TIMSK1 &= ~(1 << OCIE1B); } // Disable timer channel
|
||||
#endif
|
||||
else { DISABLE_VVT_TIMER(); } // Disable timer channel
|
||||
}
|
||||
|
||||
//The interrupt to control the Boost PWM
|
||||
|
|
Loading…
Reference in New Issue