Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

manchester code encoding using assembly code for pic

Status
Not open for further replies.

chentzin

Newbie level 5
Joined
Jul 28, 2005
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,352
manchester code pic

Does anyone has example of it?
 

pic manchester code

Hi,

Manchester encoding is pretty easy if you do it on a byte by byte basis. I assume
you know about manchester encoding, so I'll concentrate on the code.
Because its 2 manchester bits for one data bits, we are doubling the datarate so,
you're putting a byte in, and get 2 bytes out of the encoder.

All you really need is a small lookup table, with 16 entries. You can just write this by hand, as long as you decide which transistion for each bit. I use 0 = 10, and 1 = 01.
So an upward transition for a 1, and a downward one for a 0.

0000 10101010
0001 10101001
0010 10100110 etc....

The code is simple. Heres some pseudo-code.

Move 'inbyte' into W ; puts in the W register.
AND with '00001111' ; masks lower nibble, just gets rid 4 MSB's.
Call lookup table ; now that we have a 4 bit number, get lookup table entry.
Move W into 'Lowbyte' ; and move that into the 'Lowbyte' register.
SwapF 'inbyte', W ; swaps nibble of inbyte, and stores result in W.
AND with '00001111' ; again, gets rid of 4 MSB's.
Call lookup table.
Move W into 'highbyte'

Theres many methods using the lookup table. But remember, the way lookup tables work in PIC assembly, the value in the W reg, is the number of lines to 'jump', where it lands, puts the value on that line in the W and returns (with the retlw command). So, because the LUT is only 16 lines long, you must make sure that you get rid of the first 4 bits of a byte when you call the LUT. (maximum value 15). Hence the 'AND with '00001111' line. The swapf command, is handy, and allows us to do the same thing again, but for the first 4 bits (highbyte).

If you're planning on sending some data serially, quickly, you might want to put highbyte and lowbyte into a circuilar buffer (high byte first).

If you do a search of this forum, you'll find plenty of info, and many, many links to sites that explain it far better than I can. Along with source code, for any language.

Good luck

BuriedCode.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top