baseboard serial receive fifo

Hello,
I'm using baseboard serial fifo out block to receive data @ 1kHz from an external device.
The device sends a unique header byte at the beginning of each message packet.
However, message length isn't fixed. For that reason, I decided to use ordinary fifo read block instead of fifo bin read. So, I wrote my own state machine to sync with messages.
The fifo read block is configured as count + uint16 array.
even though it is working without any problem mostly, sometimes it gives some strange values.
for example,
4 39(header) byte1 byte2 checksumbyte is what I'm expecting.
But fifo read block sometime gives me something like : 4 <some integer above 255> byte1 byte 2 checksumbyte or 4 39 <some integer above 255> byte 2
what does that mean when an element of fifo read is greater than 255? Simple decomposition of that uint16 value into two uint8 values just gives some random numbers.
Any help is appreciated.

8 Kommentare

Walter Roberson
Walter Roberson am 24 Jul. 2016
Please show the line of code you use to read the port.
Gorkem
Gorkem am 24 Jul. 2016
Attached is the screen shot of my simulink model.
the problem is the output of fifo read.
Walter Roberson
Walter Roberson am 24 Jul. 2016
Could you give a specific example of expected values and received values?
Gorkem
Gorkem am 24 Jul. 2016
Here's an example
4 57 253 97 165
4 78 127 97 208
4 57 2175 2154 219
4 175 127 110 248
4 57 255 251 63
4 189 254 2066 254
4 57 254 79 136
first column corresponds to count (i.e., number of bytes in the receive fifo)
other columns are data. 57 is the header. first row is a proper data. second row isn't, there's no header in the data. but the main issue is in third and sixth rows.
what do 2175 and 2154 mean? even if there's some data corrupted in the transmission line, it seems to me that such interpretation isn't possible.
Walter Roberson
Walter Roberson am 24 Jul. 2016
The rows that are coming out wrong: what would be the correct values for those rows?
When the rows come out wrong, is the checksum correct for what the data should be, or is it correct for what the data is ?
I notice that you say that the count is the number of bytes in the receive fifo, but your diagram reads uint16. Although it is technically possible for a byte to be 16 bits, in my experience it is very rare for a byte to be anything other than 7 bits (serial transmit only), 8 bits (by far the most common), 9 bits (used in some computers in the late 1970's; also used for serial transmit with parity), or 10 bits (serial transmit only, counting the start bit)
Gorkem
Gorkem am 24 Jul. 2016
Bearbeitet: Gorkem am 24 Jul. 2016
Thanks for quick response.
next to header, there are two data bytes and the last byte is checksum.
for example : the first line has two data bytes as 253 and 97, which is to be evaluated in 2-s complement format as -671.
last line contains correct data as well. when it's interpreted as int16, it corresponds to value -433.
data is a position measurement from an external device. so for the message packets between the first and last lines, data should take values between -671 and -433.
in uint8 array form, this would be something like 254 or 253 for the first byte and some value between 0 and 255.
As for the uint16, you have a good point, but the thing is external device, which is transmitting, is a digital sensor which is configured as having data of 8 bits length and my serial board configuration is so as well.
EDIT:
Sorry I missed your question. There are 5 rows coming out wrong, which are 2 3 4 5 6
for row 2,4 and 5, checksum is wrong. for other rows among wrongs, I am not sure how to calculate checksum since they contain some bytes of 16 bits. However, if I do direct calculation, they seem to be wrong as well.
Gorkem
Gorkem am 25 Jul. 2016
Is there any reasonable explanation why I have data > 255 in the fifo output even though baseboard serial block is configured as 8 data bits?
Walter Roberson
Walter Roberson am 29 Jul. 2016
Because it is not configured as 8 data bits. Your screen snapshot shows you have configured for 16 bit output.

Melden Sie sich an, um zu kommentieren.

Antworten (3)

Gorkem
Gorkem am 24 Jul. 2016

0 Stimmen

UP! still having the issue !
Gorkem
Gorkem am 24 Jul. 2016

0 Stimmen

I also have an additional question. How does fifo receive interrupt level work? When I set it to half full or full, the problem get worse.
When I set it to 1, no data is received.
Gorkem
Gorkem am 29 Jul. 2016

0 Stimmen

I couldn't resolved the problem. Need help of anyone having the same issue

Gefragt:

am 23 Jul. 2016

Kommentiert:

am 29 Jul. 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by