So this was an X-Y problem. You don't need to change the clock speed at all for this, just use micros() - or if you need it more accurate than that, use a hardware timer (probably timer1) configured for input capture (this is exactly what input capture is made for)
Your code is almost solid problems, too.
The while loop you're using, you're expecting it to run in 50us, but you're sending a character over serial at 9600 baud, so each character takes ~1ms to send. Arduino has an output buffer on the UARTs, but I think it's only 128 bytes, and when that filled up, printing to the serial port becomes a blocking operation, leading the while loop to slow down by about a factor of 20....
This is probably not doing what you want it to - which isn't clear: uint8_t count =0,i;
Your code also doesn't seem to do anything to detect the start of the pulse...
PINB0 will always be 0. It's just a #define. PINB is the register. PINB0 is a constant that represents the bit within that register corresponding to B0 - that's the 0th bit. You would read it by doing (PINB&(1<<PINB0)).
When writing to PORTx registers, the bit names are PORTxn (ex, PORTD5), not PD5.
Here's a quick untested/off the top of my head bit of code that shows what my first approach would be to something like this.
void setup() {
Serial.begin(9600);
pinMode(
}
void loop() {
if !(PINB&(1<<PINB0)) { //equivilent to PINB&1
unsigned long start=micros();
Serial.println("starting now");
while (!(PINB&(1<<PINB0))); //sit here busywaiting until the pin goes high again.
unsigned long end=micros();
Serial.print("Pulse length was: ");
Serial.println(end-start);
}
}
Also, you should use code tags too.