Programming an ATTiny45 via Arduino and USBasp. Key part of the code is this unrolled loop where I'm writing to the port B as fast as possible :
PORTB = 0b00000001 | out; // digitalWrite(PWM, HIGH);
PORTB = 0b00000000 | out; // digitalWrite(PWM, LOW);
PORTB = 0b00000001 | out; // digitalWrite(PWM, HIGH);
PORTB = 0b00000000 | out; // digitalWrite(PWM, LOW);
... (50 repeats in total)
PORTB = 0b00000001 | out; // digitalWrite(PWM, HIGH);
PORTB = 0b00000000 | out; // digitalWrite(PWM, LOW);
Where out is a byte containing the data for the other pins set as outputs which don't change often.
I would expect this to be a 50% squarewave on the PB0 pin but instead I get a high 3 microseconds wide but the low is 4 microseconds wide !
I've tried it with internal clock of 1MHz and 8 MHz and nothing changes which also seems odd to me.
Any suggestions what I'm doing wrong ?
Thanks in advance