Seeking some advise and pointers on how to analyze and fix my program, which worked as expected on Arduino (Duemillanove), but once ported to ATtiny85, doesn't work any more.
My program decodes an ISM band (315MHz/433MHz) ASK/OOK, proprietary encoded signal on the MCU, using INT0 (external interrput), and based on detection of all transitions (high to low and low to high edges).
Some of the key differences, I can tell, are:
-
Arduino has XTAL (and thus higher precision) clock @ 16MHz, but my ATtiny is running at 8MHz using internal oscillator. My program is quite sensitive to timing, however, on Arduino, I use the standard Arduino micros() function, to determine valid (versus noise) RF signals and do the decoding, i.e. identify valid waveform vs noise. However on ATtiny85 side, I still use Arduino-Tiny, with the F_CPU rightly set (well, I trust Arduino IDE to do that for me, since I've the right Board type set), and fuse-bits blown accordingly (i.e. burn bootloader done). So, I think I am good on this part, i.e. shouldn't be an issue.
-
Pins used have obviously changed. On Arduino I was using DigitalWriteFast (user-contributed) library, that makes usage of digital Pins significantly faster compared to Arduino's standard lib for same. However, I couldn't get DigitalWriteFast to work on ATtiny85, so I made my own function, that directly uses DDRB, PORTB, PINB, with right set of masks. I've tested those functions of setting pin mode to OUTPUT/INPUT, and setting pin value HIGH/LOW etc., separately in a simple program, and they work fine. So I am ruling this aspect out (for the moment).
-
Since I depend on INT0 external interrupt, I am dependent on Arduino-tiny's support (i.e. correct implementation) for that via attachInterrupt(0,...) , and the RF data source is indeed connected to Pin#7 (INT0) on ATtiny85.
I am positive that the LED's on the outpin pins are wired up correctly. I've tested those using test program on exact same MCU using the direct port manipulation method (DDRB, PORTB... settings), and they work fine.
So I am at loss, as to what might be going wrong. Some obvious guesses (which I find tad hard to justify though) are --
A) The difference in clock is hurting me somehow on ATtiny85
B) INT0 interrupt handling in Arduino-Tiny isn't exactly correct, or maybe it's usage is bit different in ATtiny85.
C) Anything else... ?
Oh BTW, I do not have a DSO, but have a fairly functional OpenBench "Sump" LogicAnalyzer, so my troubleshooting tools are kind-of limited. Since I do not have a FTDI breakout board either, I can use Serial.print().
Thanks in anticipation.