I have a 2 uC's(LPC1778 and a PIC), that perform 2 separate functions. The PIC generates pulses that are coded,where each bit of the code has a pulse duration of 1ms and a complete code is 8 bits long(8ms). The pulses generated by the PIC,travel through a relay(having front and back contacts) and are fed to the LPC1778 as inputs.
At the LPC1778 end,I'm sampling the input pins every 200uS(using a timer interrupt) and capturing the pin state for 32ms(in the timer ISR), before processing whether a valid pulse is available or not. Once a 32ms sample is captured, I take the majority of every 5 samples to determine what the actual bit value of code is. If the code is present in any 8ms duration of the 32ms captured,its fine.
This logic(in my understanding) may work fine as long as the period for each code remains 1ms.
What my doubt is, what are the possibilities that the time period of a pulse can vary? I understand that as long as my software generates 1ms output from a pin(PIC),the input at a pin(LPC1778) also must be 1ms because this is not a wave of high frequency and also the time period of each code is known beforehand.
What else considerations must be kept in mind to ensure that I read the code rightly?
What are the possibilities that this symmetrical pattern turns to an unsymmetrical one?
Update:
Im not using it like UART where data can vary and hence timing is important. I know before hand what data should always be on that pin and hence am merely checking for that 8ms value in a 32ms sample window.I need not always keep checking for it.
void Read_FCBC(void) { static U8 bSampleNo1=0;/*1st 200us*/ static U8 bSampleNo2=0;/*2nd 200us*/ static U8 bSampleNo3=0;/*3rd 200us*/ static U8 bAllDone=0; static U8 bBufferCtrl=1; static U8 bBufferCtrl1=0; static U8 bBufferCtrl2=0; if(bBufferCtrl) { dwFC1[bSampleNo1]=dw1Port1;/*200us*/ dwBC1[bSampleNo1]=dw1Port1; bSampleNo1++; } if(bBufferCtrl1) { dwFC2[bSampleNo2]=dw2Port1;/*captured after delay of 200us wrt to sample 1*/ dwBC2[bSampleNo2]=dw2Port1; bSampleNo2++; } if(bBufferCtrl2) { dwFC3[bSampleNo3]=dw3Port1;/*captured after delay of 400us wrt to sample 1*/ dwBC3[bSampleNo3]=dw3Port1; bSampleNo3++; } bAllDone++; if(bAllDone == 1) { bBufferCtrl1=1; } if(bAllDone == 2) { bBufferCtrl2=1; } if(bSampleNo1==160) { bBufferCtrl=0; } if(bSampleNo2==160) { bBufferCtrl1=0; } if(bSampleNo3==160) { bBufferCtrl2=0; } if((bSampleNo1==160) && (bSampleNo2==160) && (bSampleNo3==160)) { bMeasureDone=0xFF; bSampleNo1=0; bSampleNo2=0; bSampleNo3=0; bAllDone=0; bBufferCtrl=1; } } The sample code for the process in ISR. Note:I have 16 FC's and 16 BC's connected to a port of the uC and hence i have to process in main(). If any 2 buffers agree with each other il use the best of 2oo3 dwFCX and dwBCX
