Thank you for this Lib. I am going to try to adapt to Attiny85. Question : I understand the assembly however if I understand the code ,the "C" code sends bytes to the assembly code and as such could this not expose the timing to how the compiler handles the code in between bytes? If there is a excessive delay between bytes would this cause an error as the Ws2812 is looking for a continuous 24 bit wave train with specific timing requirements. I expect code modified for 8 MHZ would be more susceptible. Once I convert to Attiny85 I will check timing with an oscilloscope. Also what is the code size compared to other library's like neopixel and lite_ws2812? I expect it to be much more compact. Love your tutorials !
Thanks for your feedback. Timing shouldn’t be an issue, since after compilation, code is stored in hex code. So when the controller is powered, machine code is executed during run time. As for size, my library is small compared to existing ones, and I’ll try to update by adding more functionalities. Keep in mind my tutorials are for educational purposes. Thanks again.
Nice to see that how bricks are made and brick comes to brick to finish some day the house or city - thank you
Thanks Mike
Thank you for this Lib. I am going to try to adapt to Attiny85. Question : I understand the assembly however if I understand the code ,the "C" code sends bytes to the assembly code and as such could this not expose the timing to how the compiler handles the code in between bytes? If there is a excessive delay between bytes would this cause an error as the Ws2812 is looking for a continuous 24 bit wave train with specific timing requirements. I expect code modified for 8 MHZ would be more susceptible. Once I convert to Attiny85 I will check timing with an oscilloscope. Also what is the code size compared to other library's like neopixel and lite_ws2812? I expect it to be much more compact. Love your tutorials !
Thanks for your feedback. Timing shouldn’t be an issue, since after compilation, code is stored in hex code. So when the controller is powered, machine code is executed during run time. As for size, my library is small compared to existing ones, and I’ll try to update by adding more functionalities. Keep in mind my tutorials are for educational purposes. Thanks again.
When calling ASM functions from C, would you consider prefixing the function calls with "asm" for example asmColor(0,0,255); when calling for an LED to be 100%blu. Also, do you use "keywords.txt" in your project to turn "color" function name orange?
I extended your initial 3 pixels to "n" and found timing became an issue in "high pulse" of "Logic0" and "Logic1"... see where I edited your .S file, showing timing at 0.0625us/cycle. The "high pulse" timing makes a large difference in color:
Logic0: // (0.40us + 0.85us = 1.25us)
;--------------------------
;0.40us high pulse (6T)
;----------------------
OUT PORTD, R30 ;set DIN pin HIGH
NOP // 2 timing cycles
NOP // 3 timing cycles
NOP // 4 timing cycles
NOP // 5 timing cycles
NOP // 6 timing cycles * 0.0625 = 0.375
;----------------------
;0.85us low pulse (14T)
;----------------------
OUT PORTD, R31 ;set DIN pin LOW
NOP // 2 timing cycles
NOP // 3 timing cycles
NOP // 4 timing cycles
NOP // 5 timing cycles
NOP // 6 timing cycles
NOP // 7 timing cycles
NOP // 8 timing cycles
NOP // 9 timing cycles
NOP // 10 timing cycles
NOP // 11 timing cycles
NOP // 12 timing cycles
; NOP // 13 timing cycles // for ease of including timing cycles 13 and 14
RET // 13 timing cycles * 0.625 = 0.8125 (+ 0.375 = 1.125)
;----
; RET // 14 timing cycles * 0.0625 = 0.875 (+ 0.375 = 1.25)
;====================================================================
Logic1: // (0.80us + 0.45us = 1.25us)
;---------------------------
;0.80us high pulse (13T)
;-----------------------
OUT PORTD, R30 // 1 timing cycle
NOP // 2 timing cycles
NOP // 3 timing cycles
NOP // 4 timing cycles
NOP // 5 timing cycles
NOP // 6 timing cycles
NOP // 7 timing cycles
NOP // 8 timing cycles
NOP // 9 timing cycles
NOP // 10 timing cycles
NOP // 11 timing cycles
NOP // 12 timing cycles * 0.0625 = 0.75... expected drop in pixel intensity
; NOP // 13 timing cycles * 0.0625 = 0.8125 ... sharp drop in pixel intensity
;---------------------
;0.45us low pulse (7T)
;---------------------
OUT PORTD, R31 // 1 timing cycle
NOP // 2 timing cycles
NOP // 3 timing cycles
NOP // 4 timing cycles
NOP // 5 timing cycles
NOP // 6 timing cycles
;----
RET // 7 timing cycles * 0.0625 = 0.4375 (+ 0.75 = 1.1875)
Wire 3. Two wire pawer one wire data
Is is possible to to write this specific assembly code in C?
If it's possible, how can I do that without knowing assembly?
Hi. I tried in C but no success since generating a pulse less than 1 us is difficult in C but easy in assembly. Thanks for your feedback.
Maybe use inline asm? Reference this PDF: web.stanford.edu/class/ee281/projects/aut2002/yingzong-mouse/media/GCCAVRInlAsmCB.pdf
How to make it work for ESP8266? ((