Flipped PinD2 and PinD3 (including ISR)
This commit is contained in:
parent
487d153ec7
commit
e6ff57b804
@ -49,11 +49,11 @@ int main()
|
||||
DDRB |= (1 << PORTB5); // Onboard-Led
|
||||
|
||||
// Interrupts
|
||||
// for INT0 Pin-D2 High-voltage check
|
||||
EICRA |= (0 << ISC01)|(1 << ISC00); // On at any edge [Code: 01]
|
||||
// for INT0 Pin-D2 - Counter-click
|
||||
EICRA |= (0 << ISC01)|(1 << ISC01); // On rising edge [Code: 01]
|
||||
EIMSK |= (1 << INT0); // Activate Interrupt INT0
|
||||
// for INT1 Pin-D3 Counter-click
|
||||
EICRA |= (1 << ISC11)|(1 << ISC10); // On rising edge [Code: 11]
|
||||
// for INT1 Pin-D3 - High-voltage check
|
||||
EICRA |= (1 << ISC10)|(1 << ISC11); // On any edge [Code: 11]
|
||||
EIMSK |= (1 <<INT1); // Activate Interrupt INT1
|
||||
|
||||
// Init timer1
|
||||
@ -61,11 +61,11 @@ int main()
|
||||
|
||||
PORTB |= (boost_highVoltage_nextTick << PORTB5); // Onboard-Led
|
||||
|
||||
sei(); // Activate global interrupts (after checks) [when an interrupt was fired, it will now be executed]
|
||||
|
||||
// Endless loop
|
||||
while (1)
|
||||
{
|
||||
cli(); // Deactivate global interrupts (before checks)
|
||||
|
||||
/*
|
||||
* HighVoltage boosting
|
||||
*/
|
||||
@ -124,8 +124,6 @@ int main()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sei(); // Activate global interrupts (after checks) [when an interrupt was fired, it will now be executed]
|
||||
}
|
||||
|
||||
/*
|
||||
@ -133,7 +131,7 @@ int main()
|
||||
*/
|
||||
void timer1_init()
|
||||
{
|
||||
// set up timer with speed: cpu-clock / prescaler
|
||||
// set up timer with speed = cpu-clock / prescaler
|
||||
switch(timer1_prescaler){ // [CS12 CS11 CS10]
|
||||
default:
|
||||
case 1:
|
||||
@ -167,12 +165,23 @@ void timer1_init()
|
||||
/*
|
||||
* ISR - Interrupt service routine
|
||||
*/
|
||||
// Address: 0x001 INT0 - On any edge [Code: 01]
|
||||
// Handles: Over/Below working voltage
|
||||
// Address: 0x001 INT0 - On rising edge [Code: 11]
|
||||
// Handles: Counter tube "click"
|
||||
ISR(INT0_vect)
|
||||
{
|
||||
// Tick detected, signalOutput
|
||||
signalOutput_piezo_nextTick = TCNT1; // Run as soon as possible
|
||||
signalOutput_led_nextTick = TCNT1;
|
||||
|
||||
reti(); // Exit interrupt-handler
|
||||
}
|
||||
|
||||
// Address: 0x002 INT1 - On any edge [Code: 01]
|
||||
// Handles: Over/Below working voltage
|
||||
ISR(INT1_vect)
|
||||
{
|
||||
if(!(PIND & (1 << PORTD2))) // Falling edge
|
||||
{
|
||||
{
|
||||
// Below ~400V, activate booster
|
||||
boost_highVoltage_nextTick = TCNT1; // Run as soon as possible
|
||||
PORTB |= (1 << PORTB5); // Onboard-Led
|
||||
@ -188,18 +197,7 @@ ISR(INT0_vect)
|
||||
|
||||
// reset state
|
||||
PORTD |= (0 << PORTD4); // pin on low
|
||||
|
||||
reti(); // Exit interrupt-handler
|
||||
}
|
||||
|
||||
reti(); // Exit interrupt-handler
|
||||
}
|
||||
|
||||
// Address: 0x002 INT1 - On rising edge [Code: 11]
|
||||
// Handles: Counter tube "tick"
|
||||
ISR(INT1_vect)
|
||||
{
|
||||
// Tick detected, signalOutput
|
||||
signalOutput_piezo_nextTick = TCNT1; // Run as soon as possible
|
||||
signalOutput_led_nextTick = TCNT1;
|
||||
|
||||
reti(); // Exit interrupt-handler
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user