<root>
<document schema='101' license='1,Christian Grenier,6TUUGX' title='' description='' target='PIC.16F.16F876A' >
	<config data='!0,3f3a%0,3%2,1%3,1%6,1%7,1%9,3%b,1%8,1%d,1' clkspd='20000000' simspd='1' usewdt='0' constif='0' />
	<plugins >
		<dll_dbg_icd enabled='0' >
			<data name='debug' value='1' />
			<data name='userpins' value='0' />
			<data name='speed' value='1000' />
			<data name='usev9' value='0' />
			<data name='breaks' value='8' />
			<data name='stacks' value='8' />
			<data name='clkport' value='1' />
			<data name='clkbit' value='6' />
			<data name='dataport' value='1' />
			<data name='databit' value='7' />
			<data name='monitor' value='1' />
			<data name='ictloop' value='1' />
			<data name='ictrate' value='1000' />
			<data name='ictmask' value='-1' />
		</dll_dbg_icd>
		<dll_models enabled='1' />
		<dll_upgrader enabled='1' />
		<dll_webhelp enabled='1' />
	</plugins>
	<supplement use='0' head='' body='' />
	<debug />
	<components >
		<settings autoimg='1' center='1' unitscale='0' fixedscale='0' fixedx='1' fixedy='1' fixedz='1' headcode='0' />
		<definition guid='7f6f52f0-9498-44ac-bd8a-78f986c38795' vmin='0' vmaj='1' srcleaf='' visiblename='' description='' category='' catenable='1' author='' sysinfo='0' keywords='' dynamic='0' iconpath='' />
		<component class_type='root' codename='panel' x='0' y='0' z='0' xsz='1' ysz='1' zsz='1' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' interactive='1' solid='1' layer='0' poslock='0' >
			<resources />
			<properties />
			<values />
			<events />
			<apis />
			<variables >
				<variable public='0' >
					<def class_type='variable' name='Red' type='u8' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='Blue' type='u8' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='false' type='b1' description='' isconst='1' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='Green' type='u8' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='true' type='b1' description='' isconst='1' isinit='1' usrinit='1' setinit='1' />
				</variable>
			</variables>
			<macros >
				<macro >
					<flowline name='Main' description='' >
						<command class_type='native' title='ASM Code' ccode='asm
{
; WS2812 Test library
; 20MHz internal osc
; 5MHz/instruction -&gt; 200ns/instruction
; *CC = clock cycles
    errorlevel -302, -305

    LIST P=16F876A
#include P16F876A.inc

; Config : Ext OSC, No Watchdog, No code protect
    __CONFIG _FOSC_HS &amp; _WDT_OFF &amp; _BODEN_OFF &amp; _CP_OFF &amp; _CPD_OFF

; Vars (General Purpose Registers)
RED     EQU H&apos;020&apos;
GREEN   EQU H&apos;021&apos;
BLUE    EQU H&apos;022&apos;
TEMP    EQU H&apos;023&apos;

    ORG     H&apos;00&apos;
    GOTO    init

    ORG     H&apos;05&apos;
init:
    BCF     STATUS, RP0
    BCF     STATUS, RP1 ; Set Bank 0
    CLRF    PORTA ; Clear PORTA register
    BSF     STATUS, RP0 ; Set Bank 1
    MOVLW   H&apos;07&apos; ; W_REG = 0x07
    MOVWF   ADCON1 ; ADCON1 = W_REG  -&gt;  Set PORTA to digital IO
    MOVLW   H&apos;FE&apos; ; W_REG = 0xFE
    MOVWF   TRISA ; TRISA = 0xFE  -&gt;  Set RA0 to output, all others to input

    BCF     STATUS, RP0 ; Set Bank 0
    ; Set Color
    MOVLW   _FCV_RED //Variable Red
    MOVWF   RED
    MOVLW   _FCV_GREEN //Variable Green
    MOVWF   GREEN
    MOVLW   _FCV_BLUE //Variable Blue
    MOVWF   BLUE

main:
    MOVFW   GREEN
    MOVWF   TEMP
    CALL    WS2813_SendColor
    MOVFW   RED
    MOVWF   TEMP
    CALL    WS2813_SendColor
    MOVFW   BLUE
    MOVWF   TEMP
    CALL    WS2813_SendColor
    CALL    WS2813_SendReset
    GOTO    main

WS2813_SendReset:
    BCF     PORTA, 0 ; Clear RA0
    MOVLW   H&apos;0FF&apos; ; WREG = 0xFF
WS2813_SendReset_1:
    DECFSZ  TEMP
    GOTO    WS2813_SendReset_1
    RETURN

; T0H = 400ns
; T0L = 800ns
; T1H = 800ns
; T1L = 600ns
WS2813_SendColor:
WS2813_SendColor_bit7:
    ; if (TEMP &amp; (1 &lt;&lt; 7))
    BTFSC   TEMP, 7
    ; if true
    ; send T1H + T1L
    GOTO    WS2813_SendColor_bit7_1 ;
    ; if false
    ; send T0H + T0L
    BSF     PORTA, 0 ; Set RA0
; (1)
    NOP ;                                       |   1 CC
    BCF     PORTA, 0 ; Clear RA0                |   1 CC
; (2)
; From (1) to (2), RA0 has been 0 for 2 CC = 400ns (T0H)
    GOTO    WS2813_SendColor_bit6 ;             |   2 CC

WS2813_SendColor_bit7_1:
    BSF     PORTA, 0 ; Set RA0
; (3)
    NOP ;                                       |               1 CC
    NOP ;                                       |               1 CC
    NOP ;                                       |               1 CC
    BCF     PORTA, 0 ; Clear RA0                |               1 CC
; (4)
; From (3) to (4), RA0 has been 1 for 4 CC = 800ns (T1H)

; ----- bit 7  end -----
; ----- bit 6 start ----

WS2813_SendColor_bit6:
    ; if (TEMP &amp; (1 &lt;&lt; 6))
    BTFSC   TEMP, 6
    ; if true                                   |               1 CC
    ; send T1H + T1L
    GOTO    WS2813_SendColor_bit6_1 ;           |               2 CC
    ; if false                                  |   2 CC
    ; send T0H + T0L
    BSF     PORTA, 0 ; Set RA0                  |   1 CC
; (5)
; From (2) to (5), RA0 has been 0 for 5 CC = 1000ns (T0L + 200ns)
; From (4) to (5), RA0 has been 0 for 3 CC = 600ns (T1L)
    NOP ;                                       |   1 CC
    BCF     PORTA, 0 ; Clear RA0                |   1 CC
    GOTO    WS2813_SendColor_bit5 ;             |   2 CC

WS2813_SendColor_bit6_1:
    BSF     PORTA, 0 ; Set RA0                  |               1 CC
; (6)
; From (2) to (6), RA0 has been 0 for 6 CC = 1200ns (T0L + 400ns)
; From (4) to (6), RA0 has been 0 for 4 CC = 800ns (T1L + 200ns)
    NOP ;                                       |               1 CC
    NOP ;                                       |               1 CC
    NOP ;                                       |               1 CC
    BCF     PORTA, 0 ; Clear RA0                |               1 CC

; ----- bit 6  end -----
; ----- bit 5 start ----

WS2813_SendColor_bit5:
    BTFSC   TEMP, 5
    GOTO    WS2813_SendColor_bit5_1
    BSF     PORTA, 0 ; Set RA0
    NOP
    BCF     PORTA, 0 ; Clear RA0
    GOTO    WS2813_SendColor_bit4

WS2813_SendColor_bit5_1:
    BSF     PORTA, 0 ; Set RA0
    NOP
    NOP
    NOP
    BCF     PORTA, 0 ; Clear RA0

; ----- bit 5  end -----
; ----- bit 4 start ----

WS2813_SendColor_bit4:
    BTFSC   TEMP, 4
    GOTO    WS2813_SendColor_bit4_1
    BSF     PORTA, 0 ; Set RA0
    NOP
    BCF     PORTA, 0 ; Clear RA0
    GOTO    WS2813_SendColor_bit3

WS2813_SendColor_bit4_1:
    BSF     PORTA, 0 ; Set RA0
    NOP
    NOP
    NOP
    BCF     PORTA, 0 ; Clear RA0

; ----- bit 4  end -----
; ----- bit 3 start ----

WS2813_SendColor_bit3:
    BTFSC   TEMP, 3
    GOTO    WS2813_SendColor_bit3_1
    BSF     PORTA, 0 ; Set RA0
    NOP
    BCF     PORTA, 0 ; Clear RA0
    GOTO    WS2813_SendColor_bit2

WS2813_SendColor_bit3_1:
    BSF     PORTA, 0 ; Set RA0
    NOP
    NOP
    NOP
    BCF     PORTA, 0 ; Clear RA0

; ----- bit 3  end -----
; ----- bit 2 start ----

WS2813_SendColor_bit2:
    BTFSC   TEMP, 2
    GOTO    WS2813_SendColor_bit2_1
    BSF     PORTA, 0 ; Set RA0
    NOP
    BCF     PORTA, 0 ; Clear RA0
    GOTO    WS2813_SendColor_bit1

WS2813_SendColor_bit2_1:
    BSF     PORTA, 0 ; Set RA0
    NOP
    NOP
    NOP
    BCF     PORTA, 0 ; Clear RA0

; ----- bit 2  end -----
; ----- bit 1 start ----

WS2813_SendColor_bit1:
    BTFSC   TEMP, 1
    GOTO    WS2813_SendColor_bit1_1
    BSF     PORTA, 0 ; Set RA0
    NOP
    BCF     PORTA, 0 ; Clear RA0
    GOTO    WS2813_SendColor_bit0

WS2813_SendColor_bit1_1:
    BSF     PORTA, 0 ; Set RA0
    NOP
    NOP
    NOP
    BCF     PORTA, 0 ; Clear RA0

; ----- bit 1  end -----
; ----- bit 0 start ----

WS2813_SendColor_bit0:
    BTFSC   TEMP, 0
    GOTO    WS2813_SendColor_bit0_1
    BSF     PORTA, 0 ; Set RA0
    NOP
    BCF     PORTA, 0 ; Clear RA0
    RETURN ; 2 CC

WS2813_SendColor_bit0_1:
    BSF     PORTA, 0 ; Set RA0
    NOP
    NOP
    NOP
    BCF     PORTA, 0 ; Clear RA0
    RETURN ; 2 CC

    END
}' language='C' />
					</flowline>
				</macro>
			</macros>
		</component>
	</components>
	<keymap />
	<panel2d shadows='0' lighting='2' brightness='0' perspective='0' >
		<background rgb='9737364' img='' style='0' />
		<camera xe='0' ye='0' ze='300' xt='0' yt='0' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
	</panel2d>
	<panel3d shadows='0' lighting='2' brightness='0' perspective='0' >
		<background rgb='8409120' img='' style='0' />
		<table rgb='7884836' img='' style='0' size='25' />
		<camera xe='0' ye='0' ze='300' xt='0' yt='0' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
	</panel3d>
	<layout >
		<view type='0' name='Main' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAA7AQAAHMDAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='Main' mode='1' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAA7AQAAHMDAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
	</layout>
</document>
</root>
