Purpose of sketch_sep10a is implement PCINT19 external interrupt RISING on pin D3
ext_isr(){ //Turn pin 8 enables opto-isolator on then off }
setup() { // Serial.println("s"); Enable pin 8 and pin 11 digital output, attachInterrupt on D3 to ext_isr, RISING }
loop() { // Turn pin 11 LED on then off, pin 11 connected to pin D3 }
Problem is that "s" is continuously printing on console COM9 although Arduino reset line is only once LOW
then remains HIGH, so if not repeatedly reset then what can cause setup to run and print continuously ?
Attaching .png for breadboard and Saleae trace, sketch code below:
#define D3 3
#define TRIG3 D3
int ext_isr_count = 0;
void ext_isr() {
// Interrupt handler for TRIG3 on D3, blink pin 8 LED
PORTB |= B00000001; //Turn pin 8 LED on
EIFR = 1; //Clear External Interrupt Flag 0
PCIFR = 4; //Clear Pin Change Interrupt Flag 2 for PCINT[23:16]
ext_isr_count++;
delay(1);
PORTB &= B11111110; //Turn pin 8 LED off
return;
}
void config_PCINT() {
EICRA = 3; //RISING 3 for INT0, later 15 for INT1 also
EIMSK = 1; //INT0 enable, later 3 for INT1 also
EIFR = 1; //Clear INTF0 initially, later 3 for INTF1 also
PCICR = 4; //PCINT[23:16] for PCINT19, later 6 for [14:8] also
PCIFR = 4; //PCINT[23:16], later 6 for [14:8] also
*digitalPinToPCMSK(TRIG3) |= bit(digitalPinToPCMSKbit(TRIG3));
//PCMSK2 |= (1<<PCINT19);
// Later enable PCMSK1 for PCINT9 and PCINT8
return;
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("s");
config_PCINT();
DDRB |= B00001001; //Enable pin 8 and pin 11 digital output
pinMode(8,OUTPUT);
pinMode(TRIG3, INPUT); //Enable pin D3 input for ext_isr
attachInterrupt( digitalPinToInterrupt(TRIG3), ext_isr, RISING);
}
void loop() {
// put your main code here, to run repeatedly:
// Emulate TRIG3 pulse on pin 11 digital output
PORTB = B00001000; // Turn Pin 11 LED on
delay(2);
PORTB = 0; // Turn Pin 11 LED off
delay(20);
}