Well...I have come to realize that this module is probably more trouble that it's worth. Since the row (CLOCK, /LATCH and /STROBE) lines are all tied together for the 16 row LC7932M LED driver IC (AND) the 2 sets of 16 column LC7932M LED driver ICs....all I can do is turn on one row at a time (top to bottom) whenever a column set is on.
With WDATA statements, I can pretty much display items such as a pyramid, upside down pyramid and the letters EF. (see the WDATA statements to see this). They are repeat displayed for 20 frames then the next display comes on for 20 more frames. The process repeats in a loop. This is the reason for the flickering.
See attached test file.
' =========================================================================
'
' File...... 16x32LED_v6TEST.SXB
' Purpose... SX/B interface to AD-501-B
' Author.... Timothy Gilmore (Special help and thanks to JonnyMac)
' E-mail....
gilmoret@us.saic.com
' Started... 03 JUN 2007
' Updated... 01 JUL 2007
'
' =========================================================================
' -------------------------------------------------------------------------
' Program Description
' -------------------------------------------------------------------------
' BS2 conversion program to SX-28 interface with an AD-501-B
' -------------------------------------------------------------------------
' Device Settings
' -------------------------------------------------------------------------
DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX 'Use no external resonator
'DEVICE SX28, OSCHS3, TURBO, STACKX, OPTIONX 'Use external 20 MHz resonator
FREQ 4_000_000
'FREQ 20_000_000
ID "AD-501-B"
' -------------------------------------------------------------------------
' IO Pins
' -------------------------------------------------------------------------
SIN_1 PIN RB.0
SIN_2 PIN RB.1
SIN_3 PIN RB.2
CLOCK PIN RB.3
LATCH PIN RB.4
STROBE PIN RB.5
' -------------------------------------------------------------------------
' Constants
' -------------------------------------------------------------------------
Delay CON 1 ' Set the Forward Delay time
' -------------------------------------------------------------------------
' Variables
' -------------------------------------------------------------------------
data1 VAR Word
data2 VAR Word
data3 VAR Word
tmpW1 VAR Word
tmpW2 VAR Word
result VAR Word
tmpB1 VAR Byte
tmpB2 VAR Byte
I VAR Byte
J VAR Byte
value VAR Byte
K VAR Byte
'dat2 dat3
'SIN_2 SIN_3
'xxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxx | SIN_1 data1
'0xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx0 | |
'00xxxxxxxxxxxxxx xxxxxxxxxxxxxx00 v |
'000xxxxxxxxxxxxx xxxxxxxxxxxxx000 v
'0000xxxxxxxxxxxx xxxxxxxxxxxx0000 |
'00000xxxxxxxxxxx xxxxxxxxxxx00000 |
'000000xxxxxxxxxx xxxxxxxxxx000000 v
'0000000xxxxxxxxx xxxxxxxxx0000000 on/off x-rows
'00000000xxxxxxxx xxxxxxxx00000000
'000000000xxxxxxx xxxxxxx000000000 |
'0000000000xxxxxx xxxxxx0000000000 |
'00000000000xxxxx xxxxx00000000000 |
'000000000000xxxx xxxx000000000000 |
'0000000000000xxx xxx0000000000000 v
'00000000000000xx xx00000000000000
'000000000000000x x000000000000000
'dat2b dat3b
'SIN_2 SIN_3
'000000000000000x x000000000000000 | SIN_1 data1
'00000000000000xx xx00000000000000 | |
'0000000000000xxx xxx0000000000000 v |
'000000000000xxxx xxxx000000000000 v
'00000000000xxxxx xxxxx00000000000 |
'0000000000xxxxxx xxxxxx0000000000 |
'000000000xxxxxxx xxxxxxx000000000 v
'00000000xxxxxxxx xxxxxxxx00000000 on/off x-rows
'0000000xxxxxxxxx xxxxxxxxx0000000
'000000xxxxxxxxxx xxxxxxxxxx000000 |
'00000xxxxxxxxxxx xxxxxxxxxxx00000 |
'0000xxxxxxxxxxxx xxxxxxxxxxxx0000 |
'000xxxxxxxxxxxxx xxxxxxxxxxxxx000 |
'00xxxxxxxxxxxxxx xxxxxxxxxxxxxx00 v
'0xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx0
'xxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxx
' -------------------------------------------------------------------------
' INTERRUPT 3000
' -------------------------------------------------------------------------
'ISR_Start:
'ISR_Exit:
' RETURNINT
' =========================================================================
PROGRAM Start
' =========================================================================
' -------------------------------------------------------------------------
' Subroutine Declarations
' -------------------------------------------------------------------------
CheckDataSin SUB
BITVAL FUNC 1, 2, 3 'Thanks to JonnyMac for these cool functions!
'It saved me alot of coding.
WREAD FUNC 2, 3 ' read word from WDATA
' -------------------------------------------------------------------------
' Program Code
' -------------------------------------------------------------------------
Start:
' initialization code here
LOW SIN_1 'SIN_1 is off
LOW SIN_2 'SIN_2 is off
LOW SIN_3 'SIN_3 is off
HIGH STROBE 'STROBE is off
HIGH LATCH 'LATCH is off
LOW CLOCK 'CLOCK is off (Active high)
Main:
FOR K = 1 to 20
data1 = 1 'Start from the top row (for first pattern)
FOR J = 0 TO 15
data2 = WREAD dat2, J
data3 = WREAD dat3, J
CheckDataSin
NEXT
NEXT
FOR K = 1 to 20
data1 = 1 'Start from the top row (for next pattern)
FOR J = 0 TO 15
data2 = WREAD dat2b, J
data3 = WREAD dat3b, J
CheckDataSin
NEXT
NEXT
FOR K = 1 TO 20
data1 = 1 'Start from the top row (for next pattern)
FOR J = 0 TO 15
data2 = WREAD dat2c, J
data3 = WREAD dat3c, J
CheckDataSin
NEXT
NEXT
GOTO Main
End
' -------------------------------------------------------------------------
' Subroutine Code
' -------------------------------------------------------------------------
' Use: result = WREAD table, element
' -- "table" is a WDATA table
' -- "element" is the nth word in the WDATA table
FUNC WREAD
tmpW1 = __WPARAM12 ' get table address
tmpB1 = __PARAM3 ' get element
tmpB1 = tmpB1 << 1 ' x2; convert to LSB offset
tmpW1 = tmpW1 + tmpB1 ' add offset to address
READ tmpW1, tmpW2_LSB, tmpW2_MSB
RETURN tmpW2
ENDFUNC
' Use: value = BITVAL someVal, position
' -- "someVal" can be a byte or word
FUNC BITVAL
IF __PARAMCNT = 2 THEN ' byte passed?
tmpW1 = __PARAM1 ' get byte value
tmpB1 = __PARAM2 ' get bit position
ELSE ' word passed
tmpW1 = __WPARAM12 ' word was passed
tmpB1 = __PARAM3 ' get bit position
ENDIF
tmpB2 = 0 ' assume cleared
IF tmpB1 >= 0 THEN ' position value legal?
IF tmpB1 <= 15 THEN
tmpW2 = 1 << tmpB1 ' create bit mask
tmpW2 = tmpW2 & tmpW1 ' clear other bits
IF tmpW2 > 0 THEN ' if not zero
tmpB2 = 1 ' bit was 1
ENDIF
ENDIF
ENDIF
RETURN tmpB2
ENDFUNC
CheckDataSin:
For I = 0 to 15
value = BITVAL data1, I
IF value = 1 THEN
HIGH SIN_1
ELSE
LOW SIN_1
ENDIF
value = BITVAL data2, I
IF value = 1 THEN
HIGH SIN_2
ELSE
LOW SIN_2
ENDIF
value = BITVAL data3, I
IF value = 1 THEN
HIGH SIN_3
ELSE
LOW SIN_3
ENDIF
HIGH CLOCK
LOW CLOCK
NEXT
LOW LATCH 'LATCH is on
HIGH LATCH 'LATCH is off
LOW STROBE 'STROBE is on
PAUSE Delay
HIGH STROBE 'STROBE is off
data1 = data1 << 1 'SIN_1 data is shifted from top row to bottom row
RETURN
' =========================================================================
' User Data
' =========================================================================
'Pgm_ID:
' DATA "SX/B 1.51 Template", 0
dat2:
WDATA %1111111111111111
WDATA %0111111111111111
WDATA %0011111111111111
WDATA %0001111111111111
WDATA %0000111111111111
WDATA %0000011111111111
WDATA %0000001111111111
WDATA %0000000111111111
WDATA %0000000011111111
WDATA %0000000001111111
WDATA %0000000000111111
WDATA %0000000000011111
WDATA %0000000000001111
WDATA %0000000000000111
WDATA %0000000000000011
WDATA %0000000000000001
dat3:
WDATA %1111111111111111
WDATA %1111111111111110
WDATA %1111111111111100
WDATA %1111111111111000
WDATA %1111111111110000
WDATA %1111111111100000
WDATA %1111111111000000
WDATA %1111111110000000
WDATA %1111111100000000
WDATA %1111111000000000
WDATA %1111110000000000
WDATA %1111100000000000
WDATA %1111000000000000
WDATA %1110000000000000
WDATA %1100000000000000
WDATA %1000000000000000
dat2b:
WDATA %0000000000000001
WDATA %0000000000000011
WDATA %0000000000000111
WDATA %0000000000001111
WDATA %0000000000011111
WDATA %0000000000111111
WDATA %0000000001111111
WDATA %0000000011111111
WDATA %0000000111111111
WDATA %0000001111111111
WDATA %0000011111111111
WDATA %0000111111111111
WDATA %0001111111111111
WDATA %0011111111111111
WDATA %0111111111111111
WDATA %1111111111111111
dat3b:
WDATA %1000000000000000
WDATA %1100000000000000
WDATA %1110000000000000
WDATA %1111000000000000
WDATA %1111100000000000
WDATA %1111110000000000
WDATA %1111111000000000
WDATA %1111111100000000
WDATA %1111111110000000
WDATA %1111111111000000
WDATA %1111111111100000
WDATA %1111111111110000
WDATA %1111111111111000
WDATA %1111111111111100
WDATA %1111111111111110
WDATA %1111111111111111
dat2c:
WDATA %0000000000000000
WDATA %0111111111111111
WDATA %0111111111111111
WDATA %0111100000001111
WDATA %0111100000001111
WDATA %0111100000000000
WDATA %0111100011110000
WDATA %0111111111110000
WDATA %0111111111110000
WDATA %0111100011110000
WDATA %0111100000000000
WDATA %0111100000001111
WDATA %0111100000001111
WDATA %0111111111111111
WDATA %0111111111111111
WDATA %0000000000000000
dat3c:
WDATA %0000000000000000
WDATA %0111111111111111
WDATA %0111111111111111
WDATA %0111100000001111
WDATA %0111100000001111
WDATA %0111100000000000
WDATA %0111100011110000
WDATA %0111111111110000
WDATA %0111111111110000
WDATA %0111100011110000
WDATA %0111100000000000
WDATA %0111100000000000
WDATA %0111100000000000
WDATA %0111111000000000
WDATA %0111111000000000
WDATA %0000000000000000