Hi, I am working on a program that uses an array of integers(1 and 0) to represent a gray code. For this to work I first have to take an integer and convert it to the binary, then convert the binary to gray code. The for loops i use to do this are shown below.
//Calculate Next State
my_timer_UI32++;
for(i = 0; i < SIZE; i ++){ //Decimal to binary conversion
graycode_I16[SIZE-1-i] = (int)((my_timer_UI32 >> i) & 1);
}
for(i = SIZE-1; i > 0; i --){ //binary to gray code
graycode_I16[i] = graycode_I16[i] ^ graycode_I16[i - 1];
}
My problem with this is that this graycode holds time in milliseconds so inorder to increment this I have to increment the decimal time in ms, then convert to binary, then convert to graycode again and this is taking far more time than I would like. So my question is, would it be possible to increment graycode_I16 to so that it would increment the ms by 1? Hopefully this is detailed enough, if you need more details let me know.
Thanks!