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)