Ok. A post or two back, I mentioned that I wanted to rework the receive UART because it wasn’t working perfect. I fixed that, and now it’s reliably receiving. I also mentioned that my sending uart code was solid.
Well, suffice to say, its not. 🙂
I was in the process of adding a checksum routine, and I couldnt get the stuff to come out right, and I thought I was screwing up my checksumming code, which is very simple. 8-bit MOD checksums are pretty easy. newchecksum = oldchecksum + newbyte. is all im doing.
My bit times were in the neighborhood of 540ns, and since I’m transmitting at 2mbps, they should have been 500ns on the nose. That extra 40ns is about 7.5% off, and I think normal spec for baudrates is about 3% tolerance max.
I transferred a large amount of data, and I was seeing about 1 error for every 3000 bytes. Thats .0003 error rate. Pretty good, but when you look at transferring 13824 bytes each time, that’s like 5 errors per track. Way too many. So lord knows how this was getting in my way earlier when I was having trouble getting a perfect track out of the drive.
The test ran 80000 bytes and 26 came back bad. The thing that threw me off was that the byte-counts were perfect even though the data was bad — I thought a UART issue might manifest itself by screwing up all the timing, I guess not.
Anyways, a new test, I ran 145,000 bytes through it and got 0 errors. Much better. Sent 10 times as much data as a normal track, and I got 0 errors. Very good.
The original test was sending just one character, because I figure if I can’t get any one character to transmit reliably then the whole thing is broke. The new test transmitted 5 different characters across the range, so it was a more robust test.
I used the scope to measure bit times, although measuring start and stop bit lengths can be a challenge due to the fact that they look like normal bits.
In any case, instant improvement in reliability, and I’m happy about that. Quick fix too.
I’m going to go back to my checksum stuff and put that in. I think knowing that there was a usb transfer error is very important in the overall scheme…..