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
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
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.
Any help appreciated.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
Ioannis
Last edited by Ioannis; - 14th October 2017 at 20:52.
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
Warning I'm not a teacher
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
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
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
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
Bookmarks