IEC2bits.DMA3IE=0;//disable writing to circular buffer while reading from it, without losing interrupts.
value=circular_buffer[index];//copy to remove race conditions with interupt
IEC2bits.DMA3IE=1;
// step 1: check parity
v=value.DATA[0]^value.DATA[1]^value.DATA[2];
v=(v^v>>4)&0x0f;
p=(0x6996>>v)&1;//Look-up table
if(value.DATA[0]==0&&value.DATA[1]==0&&value.DATA[2]==0&&value.STATUS==0){//while strictly speaking, this is a correct packet, it is more likely something is going wrong
if(reset_counter==0){//you need to wait at least 500us to start writing the settings. We wait for an additional 1ms so we are sure we waited long enough.