Arduino uno Timer0 won't disable

hi everyone, i'm not new to arduino but it is my first time posting a question...

Description - as part of an academic assignment, i'm trying to establish an optical wireless communication system, by using a LED and a photodiode.
Transmittion is detected by a falling edge of the optic signal on pin3, followed by the bits information.
Modulation is by OOK (On Off Keying), very simple - on or off.
every bit i'm transmitting is about 50microseconds, meaning 20Kbit/sec.
Because of real-time application, i used Timer0 interrupt configured at 100KHz, for measuring the signal 5 times, that is for 5 oversampling, which on them i use a majority decision device.
Meaning, for each byte I send - There are 40 samples, when on each 5 samples i do majority and get 1 bit of data which is stored to a byte.
I hoped i explaind the idea good enough.

my problem is, once i received 8 bits of data, i want to use the Serial port, and send the data. for not accidentally sampling wrong bits, i want to disable the interrupt. but when I use:
TIMSK0 &= ~(1 << OCIE0A); to disable the interrupt - the timer0 still operates one more time.

I know there is a lot more to it, i would be happy to answer every question there is, because i am on a deadline, and half to finish it soon.
thanx for anyone who will be willing to help.

attached the code and an image from an electric scope to help visualize the transmission.

Receiver.ino (5.2 KB)

You should probably not be messing with Timer0 as some of the standard Arduino features (such as millis()) depend on it. Try using Timer1 or Timer2

...R

That was indeed my first thought as well...

But besides that, how do you know the ISR triggers once after you did that?

Or do you disable it in the ISR? In that case, while the ISR is called an interrupt may have happened which is then "queued". Because I think that will disable the interrupt but if the flag is already set at that moment the IRS will still fire.

But besides that, how do you know the ISR triggers once after you did that?

it's not fully shown in the png file of the scope, but if I expend the time axis, it is shown that the ISR fire another 40 samples of the photodiode output.

tried other timers, configured them as well, only that the prescaler of timer1 is different since it is in much higher speed (or something of the kind...). problem remains...

after 40 ISR routines of timer0, I disable the enable bit - TOIE0 - in the register: TIMSK0. but still, the ISR is triggered once again.
also tried, clearing the interrupt flag of timer0 - OCF0A in registewr: TIFR0.

i'm going out of my mind :o ,
what wouldn't i give for debug mode like in VS?...