Hello!
I'm trying to get these two devices to communicate, without any success yet. The WS2803 is a 18 channel constant current LED driver. 2-wire communication to transmit the grayscale data, 8bits/channel. Max clock frequency up to 25MH.
http://www.jarzebski.pl/datasheets/WS2803.pdf
Operation:
After a single pulse on the CKI pin and the signal keeps LOW more than 600us, the internal logic control circuitry resets. Once reset, the internal circuitry is waiting for a positive pulse on the CKI pin. At this state, the signal on SDI pin is shifted in to the internal data registers. Once total 144 pulses are detected, WS2803 will latch the signal from the shift registers and begin the PWM operation.
I'm using a 10MHz crystal, PLL enabled and the PIC is operating at 40MHz. I'm pretty sure that all wirings are right. Common anode LEDs, anodes to +5V and cathodes to WS2803 channel pins. 1k5 resistor fom ground to IREF pin. My goal is to use the SPI at 10MHz speed but at first I'm just trying to get LEDs lit using bit bang. This code sends 0xFF to all channels. Is there something wrong in my code? Delay times maybe?
Thanks!
I'm trying to get these two devices to communicate, without any success yet. The WS2803 is a 18 channel constant current LED driver. 2-wire communication to transmit the grayscale data, 8bits/channel. Max clock frequency up to 25MH.
http://www.jarzebski.pl/datasheets/WS2803.pdf
Operation:
After a single pulse on the CKI pin and the signal keeps LOW more than 600us, the internal logic control circuitry resets. Once reset, the internal circuitry is waiting for a positive pulse on the CKI pin. At this state, the signal on SDI pin is shifted in to the internal data registers. Once total 144 pulses are detected, WS2803 will latch the signal from the shift registers and begin the PWM operation.
I'm using a 10MHz crystal, PLL enabled and the PIC is operating at 40MHz. I'm pretty sure that all wirings are right. Common anode LEDs, anodes to +5V and cathodes to WS2803 channel pins. 1k5 resistor fom ground to IREF pin. My goal is to use the SPI at 10MHz speed but at first I'm just trying to get LEDs lit using bit bang. This code sends 0xFF to all channels. Is there something wrong in my code? Delay times maybe?
Thanks!
Code:
bcf PORTA,DAI
bsf PORTA,CKI ; Short pulse CKI
nop
nop
bcf PORTA,CKI
; Delay 600us, preparing cycle
movlw 0xAF
movwf delayreg1
movlw 0x05
movwf delayreg2
Delay_loop
decfsz delayreg1,f
goto $+2
decfsz delayreg2,f
goto Delay_loop
nop
nop
;Send 144 times 1 to DAI pin (=0xFF to all 18 channels)
movlw 0x90 ; 144 to counter
movwf TEMP
bsf PORTA,DAI ; Set data bit
nop
nop
nop
nop
Send_again
bsf PORTA,CKI ; Clock pulse rising edge
nop
nop
nop
nop
bcf PORTA,CKI ; Cloc pulse falling edge
bcf PORTA,DAI ; Clear data bit
bsf PORTA,DAI ; Set data bit again
decfsz TEMP ; 144 clock pulses sent?
goto Send_again ; not yet, send more
bcf PORTA,DAI ; all sent
goto MAIN