Hi there, I am trying to recreate the sketch from this thread:
http://arduino.cc/forum/index.php?topic=74123.0 on the ATTiny85.
I am programming the 85 with arduino as ISP using the tiny cores found here:
http://code.google.com/p/arduino-tiny/I have had basic digital IO stuff working fine with these cores for some time now.
So I ported the sketch from the thread mentioned above, changing the registers to relevant ones on the 85. I'm using pin0 as the output. The problem I have is that I get a high pitched squeel very loud over the output. I tried using timer1 instead on timer0 - same problem. I have also tried an RC low-pass, doesn't reduce the squeel much.
Here is my sketch:
void setup() {
TCCR0B = (TCCR0B & 0xf8) | 1;
analogWrite(0,1);
pinMode(0,OUTPUT);
}
void putb(byte b)
{
static long m;
long t;
while((t=micros())-m < 250);
m=t;
OCR0A=b;
}
void loop() {
long v;
for(long t=0;;t++)putb(
t*((t>>12|t>>8)&63&t>>4) // by viznut
);
}
Any ideas where I'm going wrong? I'm sure this little chip is capable of making the exact same noises as the atmega328 in this way..
Thanks