In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Zoot wrote: Some of what you describe sounds like it might be noise on the lines. But looking at the flow of your main program, there is nothing to prevent a dimmer level value of 126 to mistaken for a new sync byte: [code] IF working_byte = 126 THEN byte_count = 1 \mov tx_high,working_byte \clrb tx_low.7 ' set start bit \mov tx_count,#10 '1 start + 8 data + 1 stop bit ELSE INC byte_count ENDIF [/code] I would either capture all relevant bytes to a buffer, then parse the relevant bytes once I have them all, or use a simple state machine. You could use the status of byte_count, a la: [code] IF byte_count = 0 THEN ' only check once for a packet IF working_byte = 126 THEN byte_count = 1 \mov tx_high,working_byte \clrb tx_low.7 ' set start bit \mov tx_count,#10 '1 start + 8 data + 1 stop bit ENDIF ELSE INC byte_count ENDIF IF byte_count = 2 THEN \mov tx_high,working_byte \clrb tx_low.7 ' set start bit \mov tx_count,#10 '1 start + 8 data + 1 stop bit ENDIF IF byte_count = 3 THEN ' as before '... ENDIF ' now this part I don't get -- how would byte_count ever be larger than 19 unless it's a new packet? ' seems like the tx'ed byte should be sent on byte_count = 19 (the last byte of the packet) IF byte_count = 19 THEN READ Scurve+working_byte, Level17 ENDIF IF byte_count >= 19 THEN \mov tx_high,working_byte \clrb tx_low.7 ' set start bit \mov tx_count,#10 '1 start + 8 data + 1 stop bit ENDIF [/code] [/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=449816#m449830 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2010 (http://www.dotNetBB.com)