I did a little search in the web and found that the modules for medical applications use the so called BCI protocol with 4800 8-ODD-1 serial setup.
Data frames are 5 bytes long and on the first byte the 7th bit is 1 while on the restbit 7 is set to 0.
So, may be you get one byte at a time and check the bit 7 only for it to be 1. Then get the rest and store in a byte array of 5 elements.
If there is not a sync byte or a significant pause between frame transmissions, PIC cannot discriminate the start byte. That is why you get confussing results.
One untested example might be:
IoannisCode:array var byte[5] index var byte index=0 get_new_data: SerIn2 PORTB.7,16572,[B0] if B0.7=1 then array[index]=B0 index=index+1 endif if index=5 then process_data goto get_new_data




Bookmarks