Does that OLED display library create a frame buffer? If so, it's not compatible with the t85 because the frame buffer would be 128x32 bits, which is 128×4 =512 bytes which is how much ram is available in total on the t85 leaving no room for other variables in ram.
Many of the adafruit libraries dynamically allocate buffers, so you dont fet a warning at compile tine about available ram
You are using external interrupts to measure the period between two pulses.
On the uno (ATmega328p) you have a choice of two pins (int0 and int1). On the attiny85 you have only int0.
If int0 is not free on the attiny85, you may be able to use pin change interrupts instead because these support more pins.
classic:
I am using: #include "SSD1306Ascii.h" #include "SSD1306AsciiAvrI2c.h"
for ATtiny85
as you can see in the "full sketch" in the top post.
I think you have misunderstood the question.
You must of added a core to the arduino IDE to allow you to generate code for the ATTiny series.
DrAzzy, author of post #1 in this thread maintains one. There is at least one other produced by damellis
Odd is that digitalPinToInterrupt() appears not to be supported.
TWSR and the rest of them being undefined indicates that you're using an I2C library that doesnt support the ATTiny parts (which have a USI instead of TWI peripheral of the atmega parts). It looks like avri2c display library is the offender here. Since you didnt post the full error or where the library comes from I couldn't tell you if its pulling in an incompatible version of Wire.h or implements i2c itself - if it's the former, my ATTinyCore (v1.1.x or later, iirc) includes a version of Wire.h that selects a compatible i2c implementation for the hardware you're running on; if the latter, that library cannot be made to work on the tinies without a major overhaul (reimplementing its i2c stuff to use the usi)
You also are trying to busywait in an ISR - that wont work, because interrupts are disabled while in another ISR, so millis() will not increase and it will spin forever. It would be highly likely to cause other problems as well - ISRs should aim to run almost instantly. Millis() will be thrown off if the ISR takes longer than around 1 ms to run, received serial characters will be lost before that, and so on. Only work which can only be done in the ISR should be done there.
Loading the ATtiny85:
Arduino IDE v1.8.10 - and using UNO as ISP.
I have now found the following possible problem:
I am using an OLED display - I2C - 128x32 - pin on ATtiny85 PB2 (pin7) and PB0 (pin5)
I need an external interrupt function - using and infrared “tracker sensor”.
As i can understand the ATtiny85 pin for external interrupt is also PB2 (pin7).
I have really been using Google but I cannot find any suggestions how to solve this or
actually exampels of
OK. If you have a spare Attiny85 pin, you may be able to use a pin-change interrupt instead of an external interrupt (repeated from post #4). Post a schematic diagram of your circuit (picture of a hand drawn circuit is OK) so it is clear which pins you have free.
Just to be clear, you have said that the OLED / ATtiny85 combination works for you in other projects so the issue is purely with the external interrupt ?
rename function index_pulse_time() to: ISR(PCINT0_vect)
You should also consider restructuring the sketch. Apart from what has already been mentioned about using millis() in an ISR, your attaching and detaching interrupts is odd. Better would be to leave these attached and determine the new state on any change in the ISR.
The SSD1306AsciiAvrI2c.h pulls in it's own avri2c library. Said library does not appear to be compatible with the tiny85 ir other devices that use a USI.
If you have previously made those displays work on a tiny85 (it sounds like you have), go back to your old working code and figure out what was different there. There is no way that the libraries you linked ever worked on the t85, utility/Avri2c in that library, pulled in by SSD1306AsciiAvrI2c, relies on registers that dont exist on the t85. So either you had a magic version of the library that was compatible with the tiny and used that, or you used a different library.
His problem is not just with external interrupt! The external interrupt issue is comparatively small at this point (and several of us clearly know how to solve it); until hes got the display sorted, all the interrupt-fun the world wont mak this compile.
DrAzzy - This is very important information for me. I will stop using this library of course.
Yes I have a couple of applications with this library .
These application drives display's and as input - the A0 (analog) - TrueRMA meter modules.
And in these application - NO need at all for sensors / interrupt.
I will use another library with a small foodprint for ATtiny85.
The ATTinyCore are developed by you?
Perhaps you have an exampel which I could build the design on.
rename function index_pulse_time() to: ISR(PCINT0_vect)
You should also consider restructuring the sketch. Apart from what has already been mentioned about using millis() in an ISR, your attaching and detaching interrupts is odd. Better would be to leave these attached and determine the new state on any change in the ISR.
6v6gt
I have implemented your suggestion.
When compiling / loading the code to ATtiny85 - I am getting this error:
expected unqualified-id before string constant
for this: void ISR(PCINT0_vect)
Another point - what should the index_pulse_time2() be changed to?
void ISR(PCINT0_vect){
switch(intp_flag){
case 0:break;
case 1:start_time = micros();break;
case 2:end_time = micros();
}
intp_flag = intp_flag + 1;
}
//******************************************************
void index_pulse_time2(){
if(intp_flag == 1){start_time = micros();} //read index start time
if (intp_flag == 2){end_time = micros();} //read index end time
intp_flag = intp_flag + 1 ;
}
where is this routine referenced in your sketch ? :
void index_pulse_time2()
If you post error messages from the compilation process, please include all the errors message(s) listed in the log. For example, are you still seeing a shower of error messages as listed at the end of your post #5 ?
Edit:
I've just noticed that you have not correctly answered this question from post #11:
Just to be clear, you have said that the OLED / ATtiny85 combination works for you in other projects so the issue is purely with the external interrupt ?
It was not referring to the Uno, it was referring to the combination of libraries that you are using and the ATtiny85. #include "SSD1306Ascii.h" #include "SSD1306AsciiAvrI2c.h"
Have you had these all working together in other projects ? From what DrAzzy has said in #15, this is unlikely.