PC might be the problem!

I think I’ve found at least one problem here.

My PC is at least one problem. Even though I’ve done extensive tests with the PC in the past, including measuring a 9us total cycle time, it appears the PC must slow at some point which causes data to be lost. It’s wierd, because it seems like it can keep up some of the time — other times it does just fine, then starts dropping, picks up again etc.

I wrote a little program that just transmitted a bunch of integers from the SX to the PC, and the SX waited on the PC to transmit the next one — it was really fast. I wasn’t storing the integers in memory, like I do the normal data, and perhaps that’s the difference.

Suffice to say that I put a “if byteready = 1 then BREAK” line right before the code that puts a byte on the port, I get a break within 50 bytes. Byteready *should be* zero when I go into that routine, because that would have indicated that the PC ack’d the previous byte. If byteready = 1, then that means the SX has a byte on the port, and it hasn’t been ack’d. If I reach code that is putting another byte on the port, and the previous one hasn’t been ack’d — then the PC isn’t replying fast enough.

The semi-good news is that this at least partially explains why I’m getting some good data, garbage, followed by some good data. I’ll bet my SX code is fine…..

I thought this was a problem earlier so I wrote a small software FIFO buffer on the SX. It buffers up to 16 bytes worth of data. It’s not tested real well yet, but the base code is there. I should turn this into a SUB and test it extensively so I can use it in other applications.

I’m going to put the FIFO code back in.

About the author


Amateur Electronics Design Engineer and Hacker