PCINT Flag Behavior Without Interrupt Enabled

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

'162 and avr-gcc

I want to observe a port pin to see if the PCINT status has changed, but without triggering an interrupt. Specifically, I'm looking at PINC2 which corresponds to PCINT10. When a logic change appears on the pin I would like to be able to observe the value of flag bit PCIF1 in the GIFR register. Normally, you'd have bit 4 (PCIE1) of the GICR register set so that the pin change would trigger an interrupt. I want to forgo the interrupt, and poll the flag bit at some predetermined interval, and clear it myself by writing a 1 to it.

The question is will the flag bit participate in this scheme if the GICR register hasn't enabled the corresponding interrupt? The docs are ambiguous on this and my code is giving me trouble. Maybe I'm trying to do the impossible.

I'm trying to do something like this:

	
// Near top of program.  
PCMSK1_PCINT10 = 1;    // PORTC_2 pin change enable.

/////////////////
// Lots of code.
/////////////////


ISR(TIMER0_COMP_vect)   // Happens every 500 us
{
    ++Pwm_1;
    ++Pwm_2;

    if (GIFR_PCIF1==1){			// Flag is set.
        GIFR_PCIF1=1;  			// Clears the flag!
        rpm_counter=0;
    }

    ++rpm_counter;
}

Thanks.

Greg

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, the interrupt flag will be set whether the interrupt is enabled or not (assuming that the individual pin is enabled).

Regards,
Steve A.

The Board helps those that help themselves.