FRDM2

Dependencies:   mbed

Committer:
n02655194
Date:
Fri May 08 14:10:09 2015 +0000
Revision:
1:2bba0fcfda85
Parent:
0:906202f8e2f2
final

Who changed what in which revision?

UserRevisionLine numberNew contents of line
n02655194 0:906202f8e2f2 1 #include "mbed.h"
n02655194 0:906202f8e2f2 2 #include "stdio.h"
n02655194 1:2bba0fcfda85 3 #include "math.h"
n02655194 1:2bba0fcfda85 4 #include "PortOut.h"
n02655194 0:906202f8e2f2 5
n02655194 1:2bba0fcfda85 6 //To Do:
n02655194 1:2bba0fcfda85 7 //Fix crc_passed logic
n02655194 1:2bba0fcfda85 8
n02655194 1:2bba0fcfda85 9 //Improvements:
n02655194 1:2bba0fcfda85 10 //Increase bandwidth by reducing wasted nibbles from CRC
n02655194 1:2bba0fcfda85 11
n02655194 1:2bba0fcfda85 12 //multicast using 4bit address / 4 bit network. network = 4 msb, address = 4 lsb. broadcast = all 0's. multicast = network id & address of 0's.
n02655194 0:906202f8e2f2 13 #define MAX 100 //set the size of the character data storage array
n02655194 0:906202f8e2f2 14 #define BYTE 8
n02655194 0:906202f8e2f2 15 #define PREAMBLE 0x7E //preamble of 01111110
n02655194 0:906202f8e2f2 16 #define POSTAMBLE 0x81 //postamble of 10000001
n02655194 1:2bba0fcfda85 17 #define ADDRESS 0x12 //address of 00010010 - network of 1, id of 2.
n02655194 0:906202f8e2f2 18 #define BROADCAST 0x00 //address of 00000000
n02655194 0:906202f8e2f2 19 #define CRC 0x13 //crc of 10011 or x^4+x+1 or crc-5
n02655194 0:906202f8e2f2 20
n02655194 1:2bba0fcfda85 21 Timer t; //timer for pausing after data RXed before displaying data
n02655194 1:2bba0fcfda85 22 DigitalOut myled(LED1); // red led on board
n02655194 1:2bba0fcfda85 23 BusOut db(PTC0,PTC1,PTC2,PTC3,PTC4,PTC5,PTC6,PTC7);//db0,db1,db2,db3,db4,db5,db6,db7
n02655194 1:2bba0fcfda85 24 BusOut lcdc(PTB8,PTB9,PTB10);//rs,rw,e
n02655194 1:2bba0fcfda85 25 int msecs, sksecs; //clock time needed for data transfer and skew time
n02655194 1:2bba0fcfda85 26 DigitalIn clock_pin(PTD7); //clock pulse input and data input pins
n02655194 1:2bba0fcfda85 27 DigitalInOut serial_in(PTD6);//Recieve, send for ACK
n02655194 0:906202f8e2f2 28
n02655194 1:2bba0fcfda85 29 unsigned char temp, crc_calc; //temp byte storage, storage array, transmitted crc value
n02655194 1:2bba0fcfda85 30 char c[1];//Used for troubleshooting to send a char to LCD
n02655194 1:2bba0fcfda85 31 char data[MAX];//data array
n02655194 1:2bba0fcfda85 32 unsigned char preamble, address, i, j, k, temp_data,FCS; //increment variables
n02655194 1:2bba0fcfda85 33 unsigned char data_flag, rflag, done_flag1, done_flag2; //data flags
n02655194 1:2bba0fcfda85 34 int crc_passed = 0, temp_crc = 0; //CRC Flag, stores values for crc check.
n02655194 0:906202f8e2f2 35
n02655194 0:906202f8e2f2 36 //funtion prototypes
n02655194 1:2bba0fcfda85 37 void check_byte(int value); //stays inside the function until the RXed byte matches the value passed into the function (PREAMBLE)
n02655194 1:2bba0fcfda85 38 int check_abyte();//after preamble RXed checks the next byte for address. Returns 1 if address RXed matches ADDRESS, BROADCAST, or multicast; 0 if not.
n02655194 1:2bba0fcfda85 39 int read_byte(int size); //reads RXed data and returns it a byte at a time.
n02655194 1:2bba0fcfda85 40 int get_crc(int temp_crc);//Get CRC value on data temp_crc
n02655194 1:2bba0fcfda85 41 void Ms_Delay(int msec);
n02655194 1:2bba0fcfda85 42 void lcdInit(void) ;
n02655194 1:2bba0fcfda85 43 void IC(void) ;
n02655194 1:2bba0fcfda85 44 void lcdClear(void);
n02655194 1:2bba0fcfda85 45 void print(char str[]);
n02655194 1:2bba0fcfda85 46 void send_ACK(int ACK);
n02655194 0:906202f8e2f2 47
n02655194 0:906202f8e2f2 48 int main()
n02655194 0:906202f8e2f2 49 {
n02655194 1:2bba0fcfda85 50 clock_pin.mode(PullUp);//Enable PullUp Resistors
n02655194 1:2bba0fcfda85 51 serial_in.mode(PullUp);//Enable PullUp Resistors
n02655194 1:2bba0fcfda85 52 myled=0;//Turn LED On
n02655194 1:2bba0fcfda85 53 lcdInit();//Initialize LCD
n02655194 1:2bba0fcfda85 54 //clear lcd screen, print current build message
n02655194 1:2bba0fcfda85 55 lcdClear();
n02655194 1:2bba0fcfda85 56 print("Comm Started");
n02655194 1:2bba0fcfda85 57 Ms_Delay(500);//Wait 500mS
n02655194 1:2bba0fcfda85 58 while(true) {
n02655194 1:2bba0fcfda85 59 //initialize variables
n02655194 1:2bba0fcfda85 60 i = 0;
n02655194 1:2bba0fcfda85 61 done_flag1 = 0;
n02655194 1:2bba0fcfda85 62 done_flag2 = 0;
n02655194 1:2bba0fcfda85 63 crc_passed=0;
n02655194 0:906202f8e2f2 64
n02655194 1:2bba0fcfda85 65 while(!done_flag1) {
n02655194 1:2bba0fcfda85 66 //read input clock pulse and data checking for preamble.
n02655194 1:2bba0fcfda85 67 //preamble while loop
n02655194 1:2bba0fcfda85 68 check_byte(PREAMBLE);
n02655194 1:2bba0fcfda85 69 myled=0;//Turn LED On
n02655194 0:906202f8e2f2 70 //clear lcd screen, print current build message
n02655194 1:2bba0fcfda85 71 lcdClear();
n02655194 1:2bba0fcfda85 72 print("Pre RXed");
n02655194 1:2bba0fcfda85 73
n02655194 1:2bba0fcfda85 74 //preamble RXed check address (next byte), returns to preamble check if not addressed to station
n02655194 1:2bba0fcfda85 75 if(check_abyte())
n02655194 1:2bba0fcfda85 76 done_flag1 = 1;
n02655194 1:2bba0fcfda85 77 else {
n02655194 1:2bba0fcfda85 78 //clear lcd screen, print current build message
n02655194 1:2bba0fcfda85 79 lcdClear();
n02655194 1:2bba0fcfda85 80 print("Wait for pre");
n02655194 0:906202f8e2f2 81 }
n02655194 0:906202f8e2f2 82 }
n02655194 1:2bba0fcfda85 83
n02655194 1:2bba0fcfda85 84 while(!done_flag2) {
n02655194 1:2bba0fcfda85 85 //store data into character array if crc checks.
n02655194 1:2bba0fcfda85 86 temp_data = read_byte(BYTE); //store successfully transmitted data
n02655194 1:2bba0fcfda85 87
n02655194 1:2bba0fcfda85 88 //check for postamble
n02655194 1:2bba0fcfda85 89 if(temp_data == POSTAMBLE) {
n02655194 1:2bba0fcfda85 90 //break out of while loop - data finished sending
n02655194 1:2bba0fcfda85 91 done_flag2 = 1;
n02655194 1:2bba0fcfda85 92 //clear lcd screen, print current build message
n02655194 1:2bba0fcfda85 93 lcdClear();
n02655194 1:2bba0fcfda85 94 print("Post RXed");
n02655194 1:2bba0fcfda85 95 }
n02655194 1:2bba0fcfda85 96
n02655194 1:2bba0fcfda85 97 //store data in character array if not postamble - check crc when appropriate
n02655194 1:2bba0fcfda85 98 else {
n02655194 1:2bba0fcfda85 99 //byte1, crc1, byte2, crc2
n02655194 1:2bba0fcfda85 100 data[i]=0;
n02655194 1:2bba0fcfda85 101 data[i] = temp_data;
n02655194 1:2bba0fcfda85 102 temp_crc=temp_data<<4;
n02655194 1:2bba0fcfda85 103 FCS = read_byte(BYTE); //store successfully transmitted data
n02655194 1:2bba0fcfda85 104 temp_crc=temp_crc+(FCS & 0x0F);//grab the last 4 bits from crc value byte
n02655194 1:2bba0fcfda85 105 if(get_crc(temp_crc)==0) {
n02655194 1:2bba0fcfda85 106 crc_passed=1;
n02655194 1:2bba0fcfda85 107 lcdClear();
n02655194 1:2bba0fcfda85 108 print("pass CRC");
n02655194 1:2bba0fcfda85 109 } else {
n02655194 1:2bba0fcfda85 110 crc_passed=crc_passed & 0;//needs to be fixed
n02655194 1:2bba0fcfda85 111 lcdClear();
n02655194 1:2bba0fcfda85 112 print("fail CRC");
n02655194 1:2bba0fcfda85 113 }
n02655194 1:2bba0fcfda85 114 }
n02655194 1:2bba0fcfda85 115 i++; //increment array position
n02655194 1:2bba0fcfda85 116 temp_crc = 0;//zero out crc temp variables
n02655194 1:2bba0fcfda85 117 }
n02655194 1:2bba0fcfda85 118 //pause after displaying postamble RXed and then display data.
n02655194 1:2bba0fcfda85 119 //Ms_Delay(1000);//Display Postamble Message
n02655194 1:2bba0fcfda85 120 if(crc_passed) { //if crc passes display data, send ACK
n02655194 1:2bba0fcfda85 121 //clear debugging messages - and reset lcd to original position before printing data.
n02655194 1:2bba0fcfda85 122 //send ACK
n02655194 1:2bba0fcfda85 123 lcdClear();
n02655194 1:2bba0fcfda85 124 print("RXed: ");
n02655194 1:2bba0fcfda85 125 print(data);
n02655194 1:2bba0fcfda85 126 send_ACK(0x1);
n02655194 1:2bba0fcfda85 127 // for(k=0; k<=i; k++)
n02655194 1:2bba0fcfda85 128 // print("%c", data[k]);
n02655194 1:2bba0fcfda85 129 } else { //if crc fails, send NOACK
n02655194 1:2bba0fcfda85 130 send_ACK(0x0);
n02655194 1:2bba0fcfda85 131 }
n02655194 1:2bba0fcfda85 132 myled=1;
n02655194 1:2bba0fcfda85 133 //Ms_Delay(1000);
n02655194 0:906202f8e2f2 134 }
n02655194 0:906202f8e2f2 135 }
n02655194 0:906202f8e2f2 136
n02655194 0:906202f8e2f2 137 void check_byte(int value)
n02655194 0:906202f8e2f2 138 {
n02655194 0:906202f8e2f2 139 data_flag = 1;
n02655194 0:906202f8e2f2 140 temp = 0;
n02655194 0:906202f8e2f2 141 rflag=0;
n02655194 0:906202f8e2f2 142 //while loop
n02655194 1:2bba0fcfda85 143 while(!rflag) {
n02655194 0:906202f8e2f2 144 //read in data if clock is 1 and data flag is 1
n02655194 1:2bba0fcfda85 145 if(clock_pin && data_flag) {
n02655194 0:906202f8e2f2 146 //data is left shifted into our temporary variable.
n02655194 0:906202f8e2f2 147 //each new data bit is moved into the least significant bit after the rest of the bits are shifted to the left
n02655194 0:906202f8e2f2 148 //data must be sent from the other microcontroller shifted out from the most significant bit to the least significant bit.
n02655194 0:906202f8e2f2 149 temp = (temp << 1) + serial_in;
n02655194 0:906202f8e2f2 150 data_flag = 0;
n02655194 0:906202f8e2f2 151 if(temp == value)
n02655194 0:906202f8e2f2 152 rflag = 1;
n02655194 0:906202f8e2f2 153 }
n02655194 0:906202f8e2f2 154 //when clock returns to low - reset data flag to accept the next bit.
n02655194 0:906202f8e2f2 155 if(!clock_pin && !data_flag)
n02655194 0:906202f8e2f2 156 data_flag = 1;
n02655194 0:906202f8e2f2 157 }
n02655194 0:906202f8e2f2 158 }
n02655194 0:906202f8e2f2 159
n02655194 0:906202f8e2f2 160 int check_abyte()
n02655194 0:906202f8e2f2 161 {
n02655194 0:906202f8e2f2 162 j = 0;
n02655194 0:906202f8e2f2 163 temp = 0;
n02655194 0:906202f8e2f2 164 rflag=0;
n02655194 0:906202f8e2f2 165 //while loop
n02655194 1:2bba0fcfda85 166 while(j<8) {
n02655194 0:906202f8e2f2 167 //read in data if clock is 1 and data flag is 1
n02655194 1:2bba0fcfda85 168 if(clock_pin && data_flag) {
n02655194 0:906202f8e2f2 169 //data is left shifted into our temporary variable.
n02655194 0:906202f8e2f2 170 //each new data bit is moved into the least significant bit after the rest of the bits are shifted to the left
n02655194 0:906202f8e2f2 171 //data must be sent from the other microcontroller shifted out from the most significant bit to the least significant bit.
n02655194 0:906202f8e2f2 172 temp = (temp << 1) + serial_in;
n02655194 0:906202f8e2f2 173 j++;
n02655194 0:906202f8e2f2 174 data_flag = 0;
n02655194 0:906202f8e2f2 175 }
n02655194 0:906202f8e2f2 176 //when clock returns to low - reset data flag to accept the next bit.
n02655194 0:906202f8e2f2 177 if(!clock_pin && !data_flag)
n02655194 0:906202f8e2f2 178 data_flag = 1;
n02655194 0:906202f8e2f2 179 }
n02655194 1:2bba0fcfda85 180
n02655194 0:906202f8e2f2 181 //clear lcd screen, print current build message
n02655194 1:2bba0fcfda85 182 lcdClear();
n02655194 1:2bba0fcfda85 183
n02655194 1:2bba0fcfda85 184 if(temp == ADDRESS) {
n02655194 1:2bba0fcfda85 185 rflag = 1;
n02655194 1:2bba0fcfda85 186 print("Addrss RXed");
n02655194 1:2bba0fcfda85 187 } else if(temp == BROADCAST) {
n02655194 0:906202f8e2f2 188 rflag = 1;
n02655194 1:2bba0fcfda85 189 print("Brdcst RXed");
n02655194 1:2bba0fcfda85 190 } else if(((temp & 0xF0) == (ADDRESS & 0xF0)) && ((temp & 0x0F) == 0)) {
n02655194 1:2bba0fcfda85 191 rflag = 1;
n02655194 1:2bba0fcfda85 192 print("Multicst1 RXed");
n02655194 1:2bba0fcfda85 193 } else if(((temp & 0xF0) == 0) && ((temp & 0x0F) == (ADDRESS & 0x0F))) {
n02655194 1:2bba0fcfda85 194 rflag = 1;
n02655194 1:2bba0fcfda85 195 print("Multicst2 RXed");
n02655194 1:2bba0fcfda85 196 //can add if Network==0 and address==x send to x in every network
n02655194 1:2bba0fcfda85 197 } else {
n02655194 1:2bba0fcfda85 198 print("Wrng addrss RXed");
n02655194 0:906202f8e2f2 199 }
n02655194 1:2bba0fcfda85 200 Ms_Delay(1000);
n02655194 0:906202f8e2f2 201 return rflag;
n02655194 0:906202f8e2f2 202 }
n02655194 0:906202f8e2f2 203
n02655194 0:906202f8e2f2 204 int read_byte(int size)
n02655194 0:906202f8e2f2 205 {
n02655194 0:906202f8e2f2 206 j = 0;
n02655194 0:906202f8e2f2 207 temp = 0;
n02655194 0:906202f8e2f2 208
n02655194 0:906202f8e2f2 209 //read a byte/nibble at a time and return it to main
n02655194 1:2bba0fcfda85 210 while(j<size) {
n02655194 0:906202f8e2f2 211 //read in data if clock is 1 and data flag is 1
n02655194 0:906202f8e2f2 212 if(clock_pin && data_flag) {
n02655194 0:906202f8e2f2 213 //data is left shifted into our temporary variable.
n02655194 0:906202f8e2f2 214 //each new data bit is moved into the least significant bit afater the rest of the bits are shifted to the left
n02655194 0:906202f8e2f2 215 //data must be sent from the other microcontroller shifted out from the most significant bit to the least significant bit.
n02655194 0:906202f8e2f2 216 temp = (temp << 1) + serial_in;
n02655194 1:2bba0fcfda85 217 //increment j (tracks bits RXed) - turn off data_flag until clock changes.
n02655194 0:906202f8e2f2 218 j++;
n02655194 0:906202f8e2f2 219 data_flag = 0;
n02655194 0:906202f8e2f2 220 }
n02655194 0:906202f8e2f2 221 //when clock returns to low - reset data flag to accept the next bit.
n02655194 0:906202f8e2f2 222 if(!clock_pin && !data_flag)
n02655194 0:906202f8e2f2 223 data_flag = 1;
n02655194 0:906202f8e2f2 224 }
n02655194 0:906202f8e2f2 225 return temp;
n02655194 0:906202f8e2f2 226 }
n02655194 0:906202f8e2f2 227
n02655194 1:2bba0fcfda85 228
n02655194 1:2bba0fcfda85 229 int get_crc(int temp_crc)
n02655194 1:2bba0fcfda85 230 {
n02655194 1:2bba0fcfda85 231 int j = 11, b = 0, z = 0, Y = 0, C0 = 0, C1 = 0, C2 = 0, C3 = 0;
n02655194 1:2bba0fcfda85 232 while(j > -1) {
n02655194 1:2bba0fcfda85 233 b = (temp_crc >> j) % 2;//bit
n02655194 1:2bba0fcfda85 234 Y = C3 ^ b;
n02655194 1:2bba0fcfda85 235 C3 = C2;
n02655194 1:2bba0fcfda85 236 C2 = C1;
n02655194 1:2bba0fcfda85 237 C1 = Y ^ C0;
n02655194 1:2bba0fcfda85 238 C0 = Y;
n02655194 1:2bba0fcfda85 239 j--;
n02655194 1:2bba0fcfda85 240 }
n02655194 1:2bba0fcfda85 241 z=z+C3<<1;
n02655194 1:2bba0fcfda85 242 z=z+C2<<1;
n02655194 1:2bba0fcfda85 243 z=z+C1<<1;
n02655194 1:2bba0fcfda85 244 z=z+C0;
n02655194 1:2bba0fcfda85 245 return z;
n02655194 1:2bba0fcfda85 246 }
n02655194 1:2bba0fcfda85 247
n02655194 1:2bba0fcfda85 248 void Ms_Delay(int msec)//mS Delay
n02655194 1:2bba0fcfda85 249 {
n02655194 1:2bba0fcfda85 250 t.start();
n02655194 1:2bba0fcfda85 251 //wait until the timer has reached the set time.
n02655194 1:2bba0fcfda85 252 while(t.read_ms() < msec) {
n02655194 1:2bba0fcfda85 253 }
n02655194 1:2bba0fcfda85 254 //stop and reset the timer
n02655194 1:2bba0fcfda85 255 t.stop();
n02655194 1:2bba0fcfda85 256 t.reset();
n02655194 1:2bba0fcfda85 257 }
n02655194 1:2bba0fcfda85 258
n02655194 1:2bba0fcfda85 259 void lcdInit()//Initialize LCD
n02655194 0:906202f8e2f2 260 {
n02655194 1:2bba0fcfda85 261 Ms_Delay(100);
n02655194 1:2bba0fcfda85 262 db = 0x30;
n02655194 1:2bba0fcfda85 263 Ms_Delay(2);
n02655194 1:2bba0fcfda85 264 lcdc = 0x4; //1 Enable
n02655194 1:2bba0fcfda85 265 Ms_Delay(2);
n02655194 1:2bba0fcfda85 266 lcdc = 0x0; //Disable
n02655194 1:2bba0fcfda85 267 Ms_Delay(2);
n02655194 1:2bba0fcfda85 268 db = 0xF;
n02655194 1:2bba0fcfda85 269 Ms_Delay(2);
n02655194 1:2bba0fcfda85 270 lcdc = 0x4; //1 Enable
n02655194 1:2bba0fcfda85 271 Ms_Delay(2);
n02655194 1:2bba0fcfda85 272 lcdc = 0x0; //Disable
n02655194 1:2bba0fcfda85 273 Ms_Delay(2);
n02655194 1:2bba0fcfda85 274 db = 0x1;
n02655194 1:2bba0fcfda85 275 Ms_Delay(2);
n02655194 1:2bba0fcfda85 276 lcdc = 0x4; //1 Enable
n02655194 1:2bba0fcfda85 277 Ms_Delay(2);
n02655194 1:2bba0fcfda85 278 lcdc = 0x0; //Disable
n02655194 1:2bba0fcfda85 279 Ms_Delay(2);
n02655194 1:2bba0fcfda85 280 db = 0x6;
n02655194 1:2bba0fcfda85 281 Ms_Delay(2);
n02655194 1:2bba0fcfda85 282 lcdc = 0x4; //1 Enable
n02655194 1:2bba0fcfda85 283 Ms_Delay(2);
n02655194 1:2bba0fcfda85 284 lcdc = 0x0; //Disable
n02655194 1:2bba0fcfda85 285 Ms_Delay(2);
n02655194 1:2bba0fcfda85 286 }
n02655194 1:2bba0fcfda85 287
n02655194 1:2bba0fcfda85 288 void IC() //Write to LCD
n02655194 1:2bba0fcfda85 289 {
n02655194 1:2bba0fcfda85 290 Ms_Delay(2);
n02655194 1:2bba0fcfda85 291 lcdc = 0x5; //Enable and register select high
n02655194 1:2bba0fcfda85 292 Ms_Delay(2);
n02655194 1:2bba0fcfda85 293 lcdc = 0x1; //Disable and register select low
n02655194 1:2bba0fcfda85 294 Ms_Delay(2);
n02655194 1:2bba0fcfda85 295 }
n02655194 1:2bba0fcfda85 296
n02655194 1:2bba0fcfda85 297 void lcdClear() //Clear LCD, for LPC, lcd.cls();, lcd.locate(0,3);
n02655194 1:2bba0fcfda85 298 {
n02655194 1:2bba0fcfda85 299 lcdc = 0x0; //Disable
n02655194 1:2bba0fcfda85 300 Ms_Delay(2);
n02655194 1:2bba0fcfda85 301 db = 0x1;
n02655194 1:2bba0fcfda85 302 Ms_Delay(2);
n02655194 1:2bba0fcfda85 303 lcdc = 0x4; //1 Enable
n02655194 1:2bba0fcfda85 304 Ms_Delay(2);
n02655194 1:2bba0fcfda85 305 lcdc = 0x0; //Disable
n02655194 1:2bba0fcfda85 306 Ms_Delay(2);
n02655194 1:2bba0fcfda85 307 }
n02655194 1:2bba0fcfda85 308
n02655194 1:2bba0fcfda85 309 void print(char str[])// print String to LCD Display, for LPC, printf(str);
n02655194 1:2bba0fcfda85 310 {
n02655194 1:2bba0fcfda85 311 int m=0, stl=strlen(str);
n02655194 1:2bba0fcfda85 312 while(m<stl) {
n02655194 1:2bba0fcfda85 313 db = str[m];
n02655194 1:2bba0fcfda85 314 IC();
n02655194 1:2bba0fcfda85 315 m++;
n02655194 1:2bba0fcfda85 316 }
n02655194 1:2bba0fcfda85 317 }
n02655194 1:2bba0fcfda85 318
n02655194 1:2bba0fcfda85 319 void send_ACK(int ACK)
n02655194 1:2bba0fcfda85 320 {
n02655194 1:2bba0fcfda85 321 serial_in = ACK;
n02655194 1:2bba0fcfda85 322 Ms_Delay(1500);///////////////can reduce time when Arduino Postamble delay is reduced
n02655194 1:2bba0fcfda85 323 // if(clock_pin) {
n02655194 1:2bba0fcfda85 324 // //if(!clock_pin && skew_flag && t.read_ms() > sksecs) {//output data before clock high
n02655194 1:2bba0fcfda85 325 // serial_in = (byte / j) % 2;
n02655194 1:2bba0fcfda85 326 // j /= 2; //decrement j to get to next bit location
n02655194 1:2bba0fcfda85 327 // }
n02655194 1:2bba0fcfda85 328 //reset skew flag
n02655194 0:906202f8e2f2 329 }