diff options
author | Christian Starkjohann <cs+github@obdev.at> | 2009-08-09 18:59:43 +0000 |
---|---|---|
committer | Christian Starkjohann <cs+github@obdev.at> | 2009-08-09 18:59:43 +0000 |
commit | 3aa5195808868206835073e3c1a638a5973e20d8 (patch) | |
tree | b9556d1ee1a8317cc80e603784c54c1fb98414f6 | |
parent | e48398bee7d1ec5fe2301118f1be2a160dd949bd (diff) | |
download | v-usb-3aa5195808868206835073e3c1a638a5973e20d8.tar.gz v-usb-3aa5195808868206835073e3c1a638a5973e20d8.tar.bz2 v-usb-3aa5195808868206835073e3c1a638a5973e20d8.zip |
- fixed duration of unstuffing routine for bit 6 (was one cycle too long)
-rw-r--r-- | usbdrv/Changelog.txt | 4 | ||||
-rw-r--r-- | usbdrv/usbdrvasm16.inc | 15 |
2 files changed, 13 insertions, 6 deletions
diff --git a/usbdrv/Changelog.txt b/usbdrv/Changelog.txt index 34598e9..a34fae8 100644 --- a/usbdrv/Changelog.txt +++ b/usbdrv/Changelog.txt @@ -284,3 +284,7 @@ Scroll down to the bottom to see the most recent changes. the center between bit 0 and 1 of each byte. This is where the data lines are expected to change and the sampled data may therefore be nonsense. We therefore check EOP ONLY if bits 0 AND 1 have both been read as 0 on D-. + - Fixed a bitstuffing problem in the 16 MHz module: If bit 6 was stuffed, + the unstuffing code in the receiver routine was 1 cycle too long. If + multiple bytes had the unstuffing in bit 6, the error summed up until the + receiver was out of sync. This problem was fixed. diff --git a/usbdrv/usbdrvasm16.inc b/usbdrv/usbdrvasm16.inc index 2430170..4c00faa 100644 --- a/usbdrv/usbdrvasm16.inc +++ b/usbdrv/usbdrvasm16.inc @@ -117,12 +117,15 @@ haveTwoBitsK: ; Receiver loop (numbers in brackets are cycles within byte after instr) ;---------------------------------------------------------------------------- +; duration of unstuffing code should be 10.66666667 cycles. We adjust "leap" +; accordingly to approximate this value in the long run. + unstuff6: andi x2, USBMASK ;[03] ori x3, 1<<6 ;[04] will not be shifted any more andi shift, ~0x80;[05] mov x1, x2 ;[06] sampled bit 7 is actually re-sampled bit 6 - subi leap, 3 ;[07] since this is a short (10 cycle) bit, enforce leap bit + subi leap, -1 ;[07] total duration = 11 bits -> subtract 1/3 rjmp didUnstuff6 ;[08] unstuff7: @@ -130,7 +133,7 @@ unstuff7: in x2, USBIN ;[00] [10] re-sample bit 7 andi x2, USBMASK ;[01] andi shift, ~0x80;[02] - subi leap, 3 ;[03] since this is a short (10 cycle) bit, enforce leap bit + subi leap, 2 ;[03] total duration = 10 bits -> add 1/3 rjmp didUnstuff7 ;[04] unstuffEven: @@ -139,8 +142,8 @@ unstuffEven: andi shift, ~0x80;[01] andi x1, USBMASK ;[02] breq se0 ;[03] - subi leap, 3 ;[04] since this is a short (10 cycle) bit, enforce leap bit - nop ;[05] + subi leap, -1 ;[04] total duration = 11 bits -> subtract 1/3 + nop2 ;[05] rjmp didUnstuffE ;[06] unstuffOdd: @@ -149,8 +152,8 @@ unstuffOdd: andi shift, ~0x80;[01] andi x2, USBMASK ;[02] breq se0 ;[03] - subi leap, 3 ;[04] since this is a short (10 cycle) bit, enforce leap bit - nop ;[05] + subi leap, -1 ;[04] total duration = 11 bits -> subtract 1/3 + nop2 ;[05] rjmp didUnstuffO ;[06] rxByteLoop: |