This is my first post here, first off let me know how I go.
I am going to be taking on a new project soon, to design a protocol for communication between two microcontrollers (I understand there is stuff out there but I would like to learn how low level stuff works). At the moment, I am doing some research of encodings and came across Manchester encoding, I understand how the data is sent.
But my current question is how would you get the clocks in sync, there would be a preamble in front of every message, which would give the receiver some time to detect the clock, but how would I calculate the amount of time between each read. For clarification, there would be no set transfer rate. Maybe I would have to sample the preamble every so often and see if there is a change, but maybe that could fail, if I read in the centre of a high or low.
If it is possible, I would like a detailed explanation on how I could do this, no something vague, but any information would help.
Thank you in advance.
If my question is too vague, please let me know.
EDIT: A solution through software, not hardware