jitter in usbdrvasm16.inc

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
Posts: 1
Joined: Wed Feb 15, 2017 11:33 am

jitter in usbdrvasm16.inc

Post by az3749 » Wed Feb 15, 2017 11:48 am

Code: Select all

    sbrs    shift, 0        ;[-3] [7]
    eor     x1, x4          ;[-2] [8]
    out     USBOUT, x1      ;[-1] [9] <-- out N <- jitter is here - AZ
    ror     shift           ;[0] [10]
    ror     x2              ;[1]

timing will depends of sending data. zero data (0x00) will have ~10% less duration than (0xff). USB allows only 1.5%.
It is possible to solve - make bitcnt dependent of data to compensate jitter:

Code: Select all

;   calc shift comp pare - 1+4 cycles
   ldi      bitcnt, 0xFF
   EOR      bitcnt,shift
   andi   bitcnt,0x3F
   ORI      bitcnt,0x20
   nop   ; AZ

I placed it before

Code: Select all

  dec     cnt             ;[3]
    brne    txByteLoop      ;[4]

Posts: 5
Joined: Wed Feb 15, 2017 11:44 am

Re: jitter in usbdrvasm16.inc

Post by kuro68k » Thu Feb 16, 2017 6:58 pm

Thanks for this. I'm interesting in integrating it into my code. I've noticed the jitter too. Can you post the complete TX routine?

I think the best solution would be to remove the sbrs. There is a nop in didStuff7 so you could replace it with a bst/bld, but not the other two.

The only thing I can think of at the moment is to unroll the loop.

Post Reply