Hi guys
I want to read serial pulses(serial code) that is not a standard serial.each pulse wide is 2.4us.i use arduino due for my project.what's the best way to read this code?
Example code:1110101110000111100001
The code has 22bit
Each bit wide is 2.4us
Thanks.
416,666kps?
Do you have a clock or just a data line?
Without some hardware support, this would seem challenging. Maybe it can be done in software only with interrupts disabled and using assembler.
Thanks for your reply
Yes.
Without clock.
Example code:1110101110000111100001
the length of the sequence implies the accuracy of the clock. It can't be off by ~1/length, or in this case of 22 bits, ~5%.
another aspect is when to start sampling. is the line normally high or low and is the first pulse guaranteed to be in the opposite state?
if you can recognize the start of the first pulse, do you delay by half a pulse width, 1.2uS to begin sampling in the middle of the pulse?
another possibility is to detect a change in line condition to resyncronize sampling, again delaying by half a pulse width.
if polling and using micro() for timing, is being able to delay by integer usec value sufficient?
gcjr:
if polling and using micro() for timing, is being able to delay by integer usec value sufficient?
At 16MHz 2.4us is only 40 clocks.
Using any high level function for timing is out of the question. Hardware support or instruction counting with interrupts off are the only options.
Unless of course the OP means ms?
Hardware support or instruction counting with interrupts off are the only options.
i'm not sure that is even practical for such a long sequence. there's a reason UARTs transmit only 8 bits. if both transmitter and receiver clocks can be off by 2%, the total difference can be 4%
longer sequences use various coding such that bit timing can be extracted from the data or there is a separate clock.
Unless of course the OP means ms?
it might help to know what is being transmitted and more specifically how?