jitter in usbdrvasm16.inc

Post a reply

This question is a means of preventing automated form submissions by spambots.
:D :) :( :o :shock: :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review

Expand view Topic review: jitter in usbdrvasm16.inc

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.

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]