Max I/O rate on Attiny2313 using ArduinoISP

Hello all,

This is my first post on this forum. I am working on a IR remote cloning project using Attiny2313. I have used a code which works fine if i run it on my arduino but i want to port that code to Attiny2313.

My problem is that no matter what delays i use or even dont use any delay the max rate at which i can turn off/on a LED connected to a output pin on attiny is 8Khz. Weird thing is if i select Attiny2313 @ 8Mhz rather than 1Mhz the blink speed seems to reduce than increase. Now since the carrier frequency for IR communication is 32Khz i am well short of that target.

I tried simple blink sketch and removed the delays still the oscilloscope showed that the LED was blinking at 8Khz max.

I dont know what i am doing wrong? Please help.

 Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 15; <- Pin 17 on attiny2313

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  //delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
 // delay(1000);               // wait for a second
}

digitalRead & digitalWrite are quite slow to execute so hitting the ports directly will speed things up a lot.
A better way might be to use a timer to generate the 32KHz carrier frequency.

Thank you for your reply. I will surely try the direct port manipulation. Though the timer method seems complex at first.

Weird thing is if i select Attiny2313 @ 8Mhz rather than 1Mhz the blink speed seems to reduce than increase.

Use Tools / Burn Bootloader to change the fuses.