kobre98
Full Member level 2
- Joined
- Sep 18, 2011
- Messages
- 145
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,296
- Location
- Gaza, Palestine
- Activity points
- 2,523
HI all,
i'm trying to control 8*8 rgb dot matrix
controlling the columns on/off is easy i did it with shift register
the problem i'm facing is with TLC5940 Interface with led's row
i used the following code and it works very will "it lights all the led and then turn them off in steps from 0 to 4095" for all of the three colors, the problem that i'm facing here is when i tried to control the led's using tlc it has 16 output pwm channel, i can't get a way to control which channel i want to be on/off, so i can't control it and light only one or two led's of the 64 led, it's either all or non,
here is the code
THE CODE is written in microcode studio
if any one knows how to control the channels or what should i do to write let's say "A" Letter on the dot matrix i would appreciated that,
PLZ Help ASAP
i'm trying to control 8*8 rgb dot matrix
controlling the columns on/off is easy i did it with shift register
the problem i'm facing is with TLC5940 Interface with led's row
i used the following code and it works very will "it lights all the led and then turn them off in steps from 0 to 4095" for all of the three colors, the problem that i'm facing here is when i tried to control the led's using tlc it has 16 output pwm channel, i can't get a way to control which channel i want to be on/off, so i can't control it and light only one or two led's of the 64 led, it's either all or non,
here is the code
Code:
Define OSC 32
INCLUDE "modedefs.bas"
DPIN VAR PORTB.0 ' DATA INPUT
SCLK VAR PORTB.1 ' Rising edge of SCLK shifts data from SINN pin to
' the internal register.
XLAT VAR PORTB.2 ' REGISTER LATCH :After all data is clocked in, a
'high- level pulse
'of XLAT latches the serial data to the internal registers.
BLANK VAR PORTB.3 ' RESET OUTPUT : When BLANK = H, all OUTn
'outputs are forced OFF.
'GS counter is also reset. When BLANK = L, OUTn are
'controlled by grayscale PWM control.
GSCLK VAR PORTB.4 ' Reference clock for grayscale PWM control
VPRG var PORTB.5 ' NEED TO BE AND CONNECTED
C1 var byte
C2 var byte
C3 var word
GSDATA var word
TRISB=$00
TRISC=$00
TRISA=$FF
SER VAR PORTc.0
SRCK VAR PORTc.1
RCK VAR PORTc.2
i VAR word
j VAR word
no1 VAR byte[7]
no2 VAR byte[7]
no3 VAR byte[7]
no1.0=1
no1.1=1
no1.2=1
no1.3=1
no1.4=1
no1.5=1
no1.6=1
no1.7=1
no2.0=1
no2.1=1
no2.2=1
no2.3=1
no2.4=1
no2.5=1
no2.6=1
no2.7=1
no3.0=1
no3.1=1
no3.2=1
no3.3=1
no3.4=1
no3.5=1
no3.6=1
no3.7=1
GOSUB preset
'***************************************************
'* Main Loop *
'***************************************************
LOOP:
gosub columns
for GSDATA = 0 to 4095 +64
gosub setgs
gosub lightemup
next
for GSDATA = 4095 to 0 -64
gosub setgs
gosub lightemup
next
goto LOOP
'***************************************************
'* Set GS *
'***************************************************
SETGS:
for C1 = 0 to 15 ' for 16 outputs
shiftout dpin,sclk,1,[GSDATA\12] ' shift out 12 bit GS Data
next
High XLAT ' high xlat
LOW XLAT ' low xlat
return
'***************************************************
'* LIGHT EM UP *
'***************************************************
LIGHTEMUP:
hIGH BLANK ' high blank
low blank ' All outputs = ON
for C3 = 0 to 4095 ' Generate 4096 GSCLK pulses
HIGH GSCLK ' GSCLK HIGH
LOW GSCLK ' GSCLK LOW
next
return
'***************************************************
'* Preset *
'***************************************************
PRESET:
HIGH VPRG ' Put into dot correction mode
HIGH blank ' All outputs OFF
low dpin ' Starts dot correction
low xlat
For C1 = 0 to 15 ' 16 Ports
shiftout dpin,sclk,1,[%111111\6] ' 6 bits of Dot Correction per port
next
high xlat ' Latch bits into dot correct register
low xlat
low VPRG ' Enter GS Mode
for C1 = 0 to 15
for C2 = 0 to 11
shiftout dpin,sclk,1,[%111111111111\12]
next
next
high xlat ' Latch bits into GS register
low xlat
high SCLK '193rd CLK pulse
LOW SCLK
low blank ' All outputs = ON
return
columns:
for j=7 to 0 STEP -1
SER = no1.0[j]'
SRCK = 1' // clock SRCK
SRCK = 0'
next j
for j=7 to 0 STEP -1
SER = no2.0[j]'
SRCK = 1' // clock SRCK
SRCK = 0'
next j
for j=7 to 0 STEP -1
SER = no3.0[j]'
SRCK = 1' // clock SRCK
SRCK = 0'
next j
RCK = 1' // clock RCK
RCK = 0'
pause 100
return
end
THE CODE is written in microcode studio
if any one knows how to control the channels or what should i do to write let's say "A" Letter on the dot matrix i would appreciated that,
PLZ Help ASAP