??? 09/30/08 16:56 Read: times |
#158688 - Gray Code To Binary 8051 Responding to: ???'s previous message |
Thanks again guys for all of your feedback!
At this web-site I read the following and I can get it to work for converting BINARY to GRAY. The article continues to explain that I can convert GRAY to BINARY by doing the same function 2^n-1 times. But I must be doing something wrong in my code. Take a look. Here's the link to the article. Maybe I am not reading it correctly. http://www.dspguru.com/comp.dsp/...ayconv.htm **** This works, correctly "BINARY-TO-GRAY" ****** ;Convert a Binary Number to Gray Code ;XOR the Binary Number with a copy of itself ;that has been Right Shifted (RRC) ;Example: Binary Number = 0EDH = 09BH Gray MOV BINARY,#0EDH MOV A,BINARY RRC A XRL A,BINARY **** DOES NOT WORK "GRAY-TO-BINARY" ****** ;A tricky Trick: for up to 2^n bits, you can convert Gray to binary by performing (2^n) - 1 binary-to Gray conversions. All you need is the function above and a 'for' loop. MOV GRAY_CODE,#09BH MOV R1,#255 LOOP: MOV A,GRAY_CODE RRC A XRL A,GRAY_CODE MOV GRAY_CODE,A DJNZ R1,LOOP |
Topic | Author | Date |
Gray Code To Binary 8051 | 01/01/70 00:00 | |
huge table | 01/01/70 00:00 | |
RE: Take a pen and paper | 01/01/70 00:00 | |
Here are a few places to look... | 01/01/70 00:00 | |
What for? | 01/01/70 00:00 | |
Algorithm | 01/01/70 00:00 | |
Gray Code To Binary 8051 | 01/01/70 00:00 | |
Post it | 01/01/70 00:00 | |
Yes! | 01/01/70 00:00 | |
Shifting ? | 01/01/70 00:00 | |
Gray Code To Binary 8051 | 01/01/70 00:00 | |
Posting times | 01/01/70 00:00 | |
Gray Code To Binary 8051 | 01/01/70 00:00 | |
2^n - 1 is not fast for large n | 01/01/70 00:00 | |
Ouch | 01/01/70 00:00 | |
Gray Code To Binary 8051 | 01/01/70 00:00 | |
hardware | 01/01/70 00:00 | |
gray to bin | 01/01/70 00:00 | |
asm | 01/01/70 00:00 | |
Gray Code To Binary 8051![]() | 01/01/70 00:00 |