ATTtiny44 polling

Hello:

Trying to convert a Arduino project to a Attiny44. Code is small, but I am stuck on trying to get this to compile on on the Attiny44

PCICR |= (1 << PCIE2);	//Interrupts for polling encoder
PCMSK12 |= (1 << PCINT18) | (1 << PCINT19);
sei();			// enable all interrupts

Obviously the registers are wrong, but I am really lost on the equivalent for the tiny44.

Error?

Encoder is connected to which pins?

It will not compile. There is no registers named PCICR, PCMSK12 etc. i am not sure what the equivalent would be using the Attiny44, works fine on the Arduino.

None of which answers the questions.

The error when compiling is.

Error: 'PCICR' was not declared in this scope K_Encoder:63: error: 'PCIE2' was not declared in this scope K_Encoder:64: error: 'PCMSK12' was not declared in this scope K_Encoder:64: error: 'PCINT18' was not declared in this scope K_Encoder:64: error: 'PCINT19' was not declared in this scope

The code I am using was from a project for a Arduino Uno, I want to convert the project to a Attniny44, I just don't know how to convert the code for polling from the Uno to the '44. PCIE2 and PCMSK12 are not valid registers in the '44 and i don't know what the equivalent should be.

That answers one of the two questions.

I don't have the encoder pins assigned. it does not matter to me. Whatever pins that allows me to use I can work with.

The ATtiny84 family (t84) has two I/O ports labeled A and B. Like the ATmega328 family (m328) the pin change interrupts for each I/O port are enabled by a bit in a register. For the m328 family the register is PCICR. For the t84 family the register is GIMSK.

So, to enable pin change interrupts for the pins on the A port you need to set the PCIE0 bit in the PCICR register…

 PCICR |= (1 << PCIE0);  // Enable pin change interrupts for PCINT8 through PCINT11

To enable pin change interrupts for the pins on the B port you need to set the PCIE1 bit in the PCICR regiseter…

 PCICR |= (1 << PCIE1);  // Enable pin change interrupts for PCINT0 through PCINT7

Next, you need to enable the pin change interrupt for the specific pin. That is done with the PCMSK0 and PCMSK1 registers. For example, this enables pin change interrupts for pin 0 on I/O port A (PA0; aka PCINT0)…

 PCMSK0 |= (1 << PCINT0);  // Enable pin change interrupt for PA0; PCINT0

Searching the t84 datasheet for the register names / bit names listed above will provide you with more details.

Thank you very much, this helps get me back on track.