In SX Microcontrollers, SX/B Compiler and SX-Key Tool, tdg8934 wrote: I was able to convert the PIC program over to run in SX/B. Some things were not so obvious and required playing around with it to get it to work. One item in particular are the PIC lines for the DCBA scanner on RA. Normally I would have had to use an INC RA (in or outside of an Interrupt) and I have never been able to control individual Lines for the data UNTIL NOW.... In the somewhat working SX/B conversion program below there are these 4 lines: Line_SELA VAR RA.0 Line_SELB VAR RA.1 Line_SELC VAR RA.2 Line_SELD VAR RA.3 : : Line_SELA = 0 Line_SELB = 1 Line_SELC = 1 Line_SELD = 1 This should turn on Line or Row 7 (from 0 to 15) on the Display. However, it did nothing unless I added something like INC RA in that routine (but then All 16 lines/rows turn on). What I did is added these 4 lines at the bottom of the routine and IT WORKED to all me to control individual Lines/rows. Line_SELA = ~Line_SELA Line_SELB = ~Line_SELB Line_SELC = ~Line_SELC Line_SELD = ~Line_SELD Now Line/row 7 displayed the value1 = $F0 data. This looked ok until I changed value1 data to something else and the data is not quite correct. So something is not right. And still the data in value1 copies its value across the 64 columns of LEDs (8 times). So using value1 = $F0 displays ooo----oooo----oooo----oooo----oooo----oooo----oooo----oooo----o Using value1 = $00 displays oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo Using value1 = $FF displays -------o-------o-------o-------o-------o-------o-------o-------o-------o Using value1 = $AA displays -o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o Using value1 = $0F displays ---ooooo---ooooo---ooooo---ooooo---ooooo---ooooo---ooooo---ooooo As you can see these values are not right. Here is the program below: [code] ' ========================================================================= ' ' File...... 6432d.SXB ' Purpose... Display information on 64x32 BiColor LED display ' Author.... Tim Gilmore ' E-mail.... ' Started... 24 June 2008 ' Updated... ' ' ========================================================================= ' ------------------------------------------------------------------------- ' Program Description ' ------------------------------------------------------------------------- ' ------------------------------------------------------------------------- ' Device Settings ' ------------------------------------------------------------------------- DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX, BOR22 FREQ 4_000_000 ' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- Line_SELA VAR RA.0 Line_SELB VAR RA.1 Line_SELC VAR RA.2 Line_SELD VAR RA.3 CLK VAR RB.0 ' shift clock LAT VAR RB.1 ' latch outputs DAT_R1 VAR RB.2 ' shift R1 data DAT_R2 VAR RB.3 ' shift R2 data DAT_G1 VAR RB.4 ' shift G1 data DAT_G2 VAR RB.5 ' shift G2 data Line_EN VAR RB.6 ' ------------------------------------------------------------------------- ' Constants ' ------------------------------------------------------------------------- ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- tmpW1 VAR Word k VAR Byte value1 VAR Byte i VAR Byte ' ========================================================================= PROGRAM Start ' ========================================================================= ' ------------------------------------------------------------------------- ' Subroutine Declarations ' ------------------------------------------------------------------------- DELAY_MS SUB 1, 2 ' delay in milliseconds INIT SUB 0 SENDONE SUB 0 ' ------------------------------------------------------------------------- ' Program Code ' ------------------------------------------------------------------------- Start: Main: INIT DAT_R1 = 1 'Choose to turn off upper Red LEDs DAT_R2 = 1 'Choose to turn off lower Red LEDs 'DAT_G1 = 1 'Choose to turn off upper Green LEDs (if commented then - LEDs on) DAT_G2 = 1 'Choose to turn off lower Green LEDs DO SENDONE LOOP 'GOTO Main ' ------------------------------------------------------------------------- ' Subroutine Code ' ------------------------------------------------------------------------- SUB INIT TRIS_A = %0000 ' make RA pins outputs TRIS_B = %00000000 ' make RB pins outputs ENDSUB ' Use: DELAY_MS ms ' -- delay program for 'ms' milliseconds SUB DELAY_MS IF __PARAMCNT = 1 THEN ' byte parameter? tmpW1 = __PARAM1 ELSE tmpW1 = __WPARAM12 ENDIF PAUSE tmpW1 ENDSUB SUB SENDONE Line_EN = 0 'Disable to not display Line_SELA = 1 'Turn on Line/row 7 (0-15) Line_SELB = 1 Line_SELC = 1 Line_SELD = 0 FOR k = 0 TO 7 value1 = $0F FOR i = 0 TO 7 'DAT_R1 = value1.1 'Choose to illuminate the upper in red DAT_G1 = value1.1 'Choose to illuminate the upper in green 'DAT_R2 = value1.1 'Choose to illuminate the lower in red 'DAT_G2 = value1.1 'Choose to illuminate the lower in green CLK = 0 CLK = 1 value1 = value1 >> 1 NEXT NEXT 'Required statements to control individule Lines/rows '(or just use INC RA for all 16 Lines/rows on) Line_SELA = ~Line_SELA Line_SELB = ~Line_SELB Line_SELC = ~Line_SELC Line_SELD = ~Line_SELD 'INC RA LAT = 0 LAT = 1 Line_EN = 1 'Enable to display DELAY_MS 1 ENDSUB [/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=2&m=273480#m275811 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)