Hi,
I’ve used a simple look-up table for encoding. Decoding is a little trickier, but the look-up table method for encoding is small, and pretty quick. As a ‘PIC’ user I use the instruction ‘swapf’ which swaps the nibbles of a byte, which allows you to encode each nibble seperately, meaning you only need 16 entries in the table.
eg:
0000 → 10101010
0001 → 10101001
…
0110 → 10010110
…
1111 → 01010101
The pseudo-code is pretty simple too:
Get your byte to be encoded
Store in TEMP
AND with ‘00001111’ (gets rid of the upper nibble)
Call lookup
Store result in MAN1
Get TEMP
Swap nibbles
AND with ‘00001111’ (gets rid of the upper nibble)
Call lookup
store in MAN2
I don’t know about basic, or AVR, but i’m sure most micro’s these days have that swap nibble instruciton.
Transmitting manchester encoded data works quite well with a standard UART, as the start and stop bit make a ‘10’ which is man coding for ‘0’ between nibbles. Great for syncronisation.
Hope this helps,
BuriedCode.