Go Down

Topic: Running Gray code on Due - dedicated hardware pins? (Read 174 times) previous topic - next topic

Vaclav

I recall that somewhere in ATmel docs there is a passing mention about running Gray code.
Just wondering ( cannot find it )  if it is ONLY on specific pins and limited to two bits Gray code.
Cheers Vaclav

RayLivingston

There is no single "gray code", and no hardware support should be required in most applications.  A "gray code" is any code in which only a single bit changes between successive token values.  There are gazillions of different gray code implementations for different applications.  For instance, one particular gray code counter (out of MANY possible ones), could have a sequence like this:

0 = 0b000
1 = 0b001
2 = 0b011
3 = 0b111
4 = 0b010
5 = 0b110
6 = 0b100
7 = 0b101

Regards,
Ray L.

el_supremo

Ray, that's not a gray code, the transition from 7 to 0 involves changing two bits.
This works:
Code: [Select]

0 = 0b000
1 = 0b001
2 = 0b011
3 = 0b010
4 = 0b110
5 = 0b111
6 = 0b101
7 = 0b100


Pete

RayLivingston

Ray, that's not a gray code, the transition from 7 to 0 involves changing two bits.
This works:
Code: [Select]

0 = 0b000
1 = 0b001
2 = 0b011
3 = 0b010
4 = 0b110
5 = 0b111
6 = 0b101
7 = 0b100


Pete
Yup, right you are!

Regards,
Ray L.

el_supremo

There is an algorithm to generate a gray code of any given number of bits. I had occasion to use it many years ago but I have long since forgotten it. No doubt wikipedia has an article about it, probably with a method of generating a gray code.

Pete

Go Up