Synchronous serial decoding

orbitcoms
Posts: 141
Joined: Fri Aug 03, 2018 10:08 pm
Location: Sydney, Australia

Synchronous serial decoding

Postby orbitcoms » Wed Jul 28, 2021 4:00 am

Hi

I have a serial data stream that is decoded Manchester with a re-generated clock signal.

4 bytes are expected per packet. Each time the CLOCK signal goes HIGH I need to set that bit in received stream to "1" if the DATA line is high and "0" if low.

Before embarking on discrete code writing I am wondering if there are any components or shortcuts for this.

A synch bit goes high when data is about to arrive.

Otherwise I am thinking I need
Do the following on receiving the synch bit
Set a timer to ensure function stops if invalid/incomplete packet received
While time has not expired
Wait for CLOCK high
Read DATA line and set bit if it is high else leave as 0
Shift the bit left into uint32_t
Wait for CLOCK line to go low
Repeat for next 31 bits then escape the loop
If time expires then flag as invalid packet and wait for next synch bit.

If I revert to this, would I be better to set the CLOCK pin as interrupt for POSEDGE and do the read and shift in the ISR (or set flag in ISR that main routine then does the read and shift)?

Thanks

Who is online

Users browsing this forum: No registered users and 153 guests