adafruit / Adafruit_CircuitPython_DotStar

Dotstarrin' away in CircuitPython land
MIT License
46 stars 38 forks source link

_ds_writebytes() clock rises before data is written #34

Closed kevinjwalters closed 4 years ago

kevinjwalters commented 5 years ago

@schelmo has noted that clock rises before data bit is written on the bitbanging implementation in _ds_writebytes() in https://github.com/adafruit/Adafruit_CircuitPython_WS2801/pull/4

That code is the same and probably originated from here. Check origins of this code and find other occurrences. Forum post to see if anyone is using non hardware assisted pins, i.e. why has this only just been noticed.

(This could be a direct translation of some flawed C code which worked because timing was far tighter??)

schelmo commented 5 years ago

i tested this with dotstars now (trinket m0, data -> d0, clock -> d1) no weird colors like for the ws2801 if i rise the clock pin after the data bit is written (like in pull request adafruit/Adafruit_CircuitPython_WS2801#4), everything still works like expected

ladyada commented 5 years ago

@schelmo wanna submit a PR here too? :)

kevinjwalters commented 5 years ago

The APA102C datasheet from DotStar Addressable 5050 RGB LED does make it look like these are edge triggered on the rising edge for reading data from DI:

adafruit-dotstar-shiji-apa102c-datasheet-dataclock-snippet

Curious that it works either way with CircuitPython, though.

kevinjwalters commented 5 years ago

The C/C++ code in https://github.com/adafruit/Adafruit_DotStar/blob/master/Adafruit_DotStar.cpp has three implementations - the two non-hardware assisted ones in that code all do clocking after the data is set as one would expect.

This (deprecated) https://github.com/adafruit/Adafruit_DotStar_Pi/blob/master/dotstar.c#L472 code seems a bit similar to above. Data is correctly asserted before clock pulsing in that.

kattni commented 4 years ago

Fixed by #35