I cannot imagine a device keep sending a blast of bytes without any synchronization!
Please give us a link for the data sheet or if small post it here.
Ioannis
I cannot imagine a device keep sending a blast of bytes without any synchronization!
Please give us a link for the data sheet or if small post it here.
Ioannis
Many devices send continuous blasts of data.
Here's a definition for spo2 http://www.neann.com/spo2.htm. A manual for the specific device would be helpful.
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
The SpO2 module I use is of none parity.
I wonder the PIC have the problem to read the bytes if the bytes are sent into PIC in endless stream. I tried to send only 5 bytes, 10 bytes and 15 bytes data in SpO2 module's data format and the PIC can process well using the code I wrote.
Then I tried to let PIC sent out each byte it read in from a endless bytes stream. The output of the PIC is different from the data it read in.
That's not the issue. How many STOP bits is the issue. If, as the only reference I could find for the BCI protocol says, it uses 8N2, you cannot handle it - all of the PBP methods require 1 stop bit. Two stop bits could explain the erratic results. You need to provide a link to the datasheet for the specific SP02 device you are using.
Last edited by dhouston; - 16th June 2009 at 11:56.
Bookmarks