WS2811 and WS2812 One-Wire Communication Assembly Help


Closed Thread
Results 1 to 25 of 25

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default Re: One-Wire Communication Assembly Help

    Thanks. Assembly is not something that I'm very familiar with. I'll go over this code. It seem to do what I need.

    Robert
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default WS2811 One-Wire Communication Assembly Help

    I am after such a project too. Unfortunately Assembly is not too friendly.

    I found this AN from Microchip, AN1606 that uses the CLC module on some new chips, like the 16F1509.

    After a cryptic analysis of the timing using TMR, PWM and CLC modules, the AN claims that can produce the strict timing required for the WS2811 chip.

    Well, only the setting is shown and not the use of this settings on the PIC.

    Anyone has any idea how to use the PIC for sending the RGB data?

    Following is the settings for the 1509 registers to obtain the correct timing on the RC4/CLC4 port pin #6, based on the slow mode of WS2811.

    Code:
    ' Initialize PIC16(L)F1509 CLC2, CLC4, Timer2, and MSSP
    ' for WS2811 signal transmission protocol
    ' Loading SSP1BUF register sends that data byte out the RC4/CLC4 pin
    ' PWM1 routed straight through CLC2
    CLC2GLS0 = $20
    CLC2GLS1 = $00
    CLC2GLS2 = $00
    CLC2GLS3 = $00
    CLC2SEL0 = $00
    CLC2SEL1 = $06
    CLC2POL = $0E
    CLC2CON = $82;
    
    ' (SPI SDO & SPI CLK) || (nSPI SDO & SPI CLK & PWM1)
    ' PWM1 comes through CLC2
    CLC4GLS0 = $44
    CLC4GLS1 = $10
    CLC4GLS2 = $80
    CLC4GLS3 = $20
    CLC4SEL0 = $50
    CLC4SEL1 = $05
    CLC4POL = $01
    CLC4CON = $C0
    
    ' Adjust Timer2 period for desired baud rate
    ' One bit period is two Timer2 periods
    T2CON = $04
    PR2 = 5
    ' Adjust PWM1 duty cycle for desired "0" data-bit duty cycle
    ' ‘1’ data-bit duty cycle is automatically 50%
    PWM1CON = $E0
    PWM1DCH = 2
    PWM1DCL = 0
    
    ' MSSP configured for SPI master with Timer2_Period/2 clock
    SSP1CON1 = $23
    
    ' Output on RC4/CLC4
    TRISC = $EF
    Any help appreciated.

    Ioannis
    Last edited by Ioannis; - 14th October 2017 at 20:52.

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: WS2811 and WS2812 One-Wire Communication Assembly Help

    interesting find ioannis.

    the an seems to lack many details not just how to use it ,I tried it out on a pic16f1619 and discovered that the an description of the clc cells setup is quite misleading

    the reality is they are set like in these images


    I'm not sure I have this exactly correct but it looks to work

    i have included my working example it spits out data for 64 leds [192 bytes] in 2mS.

    I cant see much advantage to it over my earlier routine you only have a few uS between bytes barely enough time for a pbp style dt interrupt
    Attached Images Attached Images   
    Attached Files Attached Files
    Warning I'm not a teacher

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: WS2811 and WS2812 One-Wire Communication Assembly Help

    a small refinement
    CLC1 can be released from use its not needed with a 16f1619

    by

    CLC2SEL1 = $0E; in lieu of 04
    Warning I'm not a teacher

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: WS2811 and WS2812 One-Wire Communication Assembly Help

    Richard, thanks for looking into this.

    For 64 led's I think the timing for each frame is 3,84ms. Does it work with 2ms?

    Anyway, you did a great job on this. Really fast!

    Well, the AN implied, or at least I wanted to be that way, this solution would be fast enough for the MCU to do other tasks.

    But as you tested, yes, seems there is not enough time.

    I want to use this strips for a 60 led's (1m bar) for medical purposes and the timing is very strict.

    Thanks,
    Ioannis

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: WS2811 and WS2812 One-Wire Communication Assembly Help

    I may have measured that wrong, its more like 5mS now for 192 bytes


    the spi takes 25uS per byte and there is a 5us gap between bytes as is

    I think the gap between bytes needs to be less than 50uS

    so an isr has 60us to get in do something and get out again

    conversely an asm isr could feed the spi buffer every 60uS or so
    Warning I'm not a teacher

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: WS2811 and WS2812 One-Wire Communication Assembly Help

    just for a joke I upped the osc to 32mHz ,
    it still works , its less than 3mS now for 192 bytes
    these things aren't that fussy
    Warning I'm not a teacher

Similar Threads

  1. PIC to WS2812B / WS2811 IC
    By comwarrior in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 19th January 2018, 19:37
  2. ws2812 - pic12f1822
    By richard in forum Code Examples
    Replies: 0
    Last Post: - 12th January 2016, 09:52
  3. Assembly
    By Normnet in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 19th March 2007, 03:44
  4. How do you do this in Assembly
    By ice in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th May 2005, 06:47
  5. Assembly?
    By Dwayne in forum General
    Replies: 11
    Last Post: - 4th January 2004, 18:18

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts