I'm programming an ATTiny 85 using the Arduino IDE and an Arduino Nano as "Arduino as ISP" to program the ATTiny. I succeeded a week ago and now I want to program a second chip but get the 'GIMSK' was not declared in this scope
error during compile.
The GIMSK is called at the start of the sleep()
function. I tried adding #include <avr/interrupt.h>
but continue to receive the compile error.
#include <avr/sleep.h> // Sleep Modes
#include <avr/power.h>
#include <elapsedMillis.h>
const int hallPin = 2; // the number of the hall effect pin
const int magnetPin = 1; // the number of the magnet pin
const long debouncing_time = 15; //Debouncing Time in milliseconds
// variables will change:
volatile int hallState = 0; // variable for storing the hall counter
volatile unsigned long last_micros;
elapsedMillis timer;
void setup()
{
pinMode(magnetPin, OUTPUT);
pinMode(hallPin, INPUT);
digitalWrite(hallPin, HIGH); // pullup enabled.
// Attach an interrupt to the ISR vector
attachInterrupt(0, pin_ISR, RISING); //default interupt pin is always 0 on attiny85 (physical pin 7)
timer = 0;
}
void sleep()
{
GIMSK |= _BV(PCIE); // Enable Pin Change Interrupts
PCMSK |= _BV(PCINT2); // Use PB2 as interrupt pin
ADCSRA &= ~_BV(ADEN); // ADC off
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // replaces above statement
sleep_enable(); // Sets the Sleep Enable bit in the MCUCR Register (SE BIT)
sei(); // Enable interrupts
sleep_cpu(); // sleep
cli(); // Disable interrupts
PCMSK &= ~_BV(PCINT2); // Turn off PB2 as interrupt pin
sleep_disable(); // Clear SE bit
ADCSRA |= _BV(ADEN); // ADC on
sei(); // Enable interrupts
} // sleep
etc.
Can anyone give me a pointer? I had saved my work so I'm puzzled by the error.
Thank you.
Solution:
Programming configuration for the ATTiny 85 via the Nano as ISP.