Direct port addressing error

Hi,
I have an ATtiny84 with Core from Spence Konde. The documentation says:

To refer to pins by port and bit, use PIN_Pxn (ex, PIN_PB2); these are #defined to the Arduino pin number for the pin in question, and can be used wherever digital pin numbers can be used.

Within an interrupt routine I use it:

ISR(TIM1_COMPB_vect) {
  PIN_PB2=0;  // Triac feuern <<<< this is line 55
}

The compiler reports an error:

H:\Arduino\examples\MotorRegler\MotorRegler.ino: In function 'void __vector_7()':
MotorRegler:55:11: error: lvalue required as left operand of assignment
   PIN_PB2=0;  // Triac feuern
           ^

I don't understand this " lvalue required as left operand of assignment". What is wrong with "0" ?
I also tried PORT_PB2 instead of PIN_PB2 because somewhere I read to use PORT for output and PIN for input from ports. But the compiler doesn't like it too: " PORT_PB2 not defined".

There are a lot of "somewhere" bits of advice that are totally wrong. Please post your entire error output, not just a snippet.

That’s how PIN_PB2 is defined… see the issue?

Thank you very much. These defines explain the error message.

Google said have a look at this

It's like the documentation you quoted says:

You can't use this to set Pin 2 LOW:
2 = LOW;
You have to use:
digitalWrite(2, LOW);
So you can't use this:
PIN_PB2 = LOW;
You have to use this:
digitalWrite(PIN_PB2, LOW);

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.