' BOB-1.BS2 ' ' A sample program to exercise BOB-I via a Parallax Basic Stamp II. ' (At the heart of BOB-I is the Rohm BU5963AS IC). ' ' (C) Copyright 1997 by Christopher L. Oesterling. Assigned to Decade ' Engineering on July 2, 1997. Decade Engineering hereby grants permission ' to use or distribute this document freely, as long as this header remains ' fully intact. Visit Decade's Web Site for the latest App Notes, product & ' price information, bug fixes, hot links to other vendors and developers. ' Decade's URL is: http://www.decadenet.com ' ' All responsibility for the effects (or lack of effects) of this code lies ' with the developer who uses it. Decade Engineering accepts no liability ' of any sort in connection with its use or misuse. The use of Decade's ' products in human life-support applications is explicitly prohibited. ' ' Connect BOB-I to the Basic Stamp II as follows: ' ' Stamp II pin 4 (GND) -> BOB-I (GND) J4 pin 6 ' Stamp II pin 5 (I/O 0) -> BOB-I (Chip Select) J4 pin 5 ' Stamp II pin 6 (I/O 1) -> BOB-I (Data Input) J4 pin 3 ' Stamp II pin 7 (I/O 2) -> BOB-I (Clock Input) J4 pin 4 ' ' Note: More than one version of the J4 pin assignment has been used in ' production of BOB-I boards. The listing above is correct for Rev. 1.1 ' boards. ' ' For many applications, BOB-I's control register settings may be hard-coded, ' which frees up most of the Stamp's memory and program area that is ' consumed by this program. ' DIRS = %0000000000000111 ' Input pins are 0, output pins are 1, and pin 0 is ' the right most bit. So make pins 2, 1, and 0 outputs. ' constants for pins c_CS CON 0 ' pin 0 - chip select (low listen to us, high ignore us) c_DATA CON 1 ' pin 1 - data c_CLOCK CON 2 ' pin 2 - clock ' constants for color - actual colors will vary! c_BLACK CON 0 c_RED CON 1 c_GREEN CON 2 c_YELLOW CON 3 c_BLUE CON 4 c_MAGENTA CON 5 c_CYAN CON 6 c_WHITE CON 7 ' BU5963AS IC horizontal register (240) starth VAR BYTE ' display starting position (6 bits) size1h VAR NIB ' char size for top line (2 bits) size2h VAR NIB ' char size for all other lines (2 bits) ' leftover bits (6 bits) ' BU5963AS IC vertical register (241) startv VAR BYTE ' display starting position (6 bits) size1v VAR NIB ' char size for top line (2 bits) size2v VAR NIB ' char size for all other lines (2 bits) ' leftover bits (6 bits) ' BU5963AS IC color register (242) bkcol VAR NIB ' main background color (3 bits) cscol VAR NIB ' char background color (3 bits) olcol VAR NIB ' char outline color (3 bits) ' leftover bits (7 bits) ' BU5963AS IC misc. register (243) omode VAR NIB ' output mode, 1=norm(?), table in data (3 bits) bfreq VAR BIT ' blink frequency, 0=fast, 1=slow (1 bit) bduty VAR NIB ' blink duty-- off, 25%, 50%, 75% (2 bits) bi VAR BIT ' if blink off, 0 sets reverse/blank chars (1 bit) brb VAR BIT ' blink mode, 1=blank, 0=reverse video (1 bit) oline VAR BIT ' char outline control, 1=on (1 bit) csize VAR BIT ' char background control, 1=on (1 bit) port1 VAR BIT ' digital output port1, 1=high (1 bit) port2 VAR BIT ' digital output port1, 1=high (1 bit) port3 VAR BIT ' digital output port1, 1=high (1 bit) ' leftover bits (3 bits) ' BU5963AS IC character data (0 -> 239) ochar VAR BYTE ' ascii char to display (8 bits) blnk VAR BIT ' 1=blink/rev on, 0=blink/rev off (1 bit) color VAR NIB ' color for this char (3 bits) spc VAR BIT ' 1=superimpose (normal), 0=RGB out (1 bit) ' leftover bits(3 bits) ' variables addrparm VAR BYTE ' requested location to address in the BU5963AS's ' memory 0->239 characters, 240->243 registers cnt VAR BYTE ' temp variable in clrscr function n VAR BYTE ' temp variable in main function x VAR BYTE ' ditto y VAR BYTE ' ditto main: pause 1000 ' make sure BOB-1 is awake low c_Clock ' bring the clock line low to avoid data being sent low c_CS ' select the BU5963AS IC so it will listen to us gosub initregs ' init all BU5963AS IC registers gosub clrscr ' clear the screen ' set attributes for the characters to be drawn spc = 1 ' superimpose blnk = 0 ' no blink color = c_WHITE ' white characters read mylinex, x read myliney, y addrparm = x + (y * 24) ' draw white text starting at column 6, row 5 gosub setaddr n = 0 :loop read myline + n, ochar if ochar = 0 then done gosub sendchar n = n + 1 goto loop done: high c_CS ' unselect the BU5963AS IC since we're all done ' only needs to be done at the very end of your app end ' ' initialize all BU5963AS IC registers ' initregs: starth = 41 ' See the Rohm document for what all these size1h = 0 ' register values do. size2h = 0 startv = 41 size1v = 0 size2v = 0 bkcol = 0 cscol = 0 olcol = 0 omode = 1 ' 1 for overlay text on video-in source ' 6 for BOB-1 to generate black screen bfreq = 0 bduty = 3 bi = 0 brb = 0 oline = 1 csize = 0 port1 = 0 port2 = 0 port3 = 0 addrparm = 240 ' base address for control registers gosub setaddr ' address will auto increment ' send horizontal register shiftout c_DATA, c_CLOCK, LSBFIRST, [starth\6, size1h\2, size2h\2, 0\6] ' send vertical register shiftout c_DATA, c_CLOCK, LSBFIRST, [startv\6, size1v\2, size2v\2, 0\6] ' send color register shiftout c_DATA, c_CLOCK, LSBFIRST, [bkcol\3, cscol\3, olcol\3, 0\7] ' send misc. register shiftout c_DATA, c_CLOCK, LSBFIRST, [omode\3, bfreq\1, bduty\2, bi\1, brb\1, oline\1, csize\1, port1\1, port2\1, port3\1, 0\3] return ' ' clrscr clears display ram ' clrscr: addrparm = 0 ' set address to first position in memory gosub setaddr ' Fill ram with white blanks. The BU5963AS IC interprets black chars ' (even blanks) as transparent, and they wouldn't show up when ' reversed, which would prevent the cursor from showing. ochar = " " color = c_WHITE blnk = 0 spc = 1 for cnt = 1 to 240 gosub sendchar next return ' ' setaddr loads the address register ' setaddr: ' set address mode bit (13) with address shiftout c_DATA, c_CLOCK, LSBFIRST, [(addrparm | $2000)\16] return ' ' send one character (and attribute info) to the BU5963AS IC ' sendchar: shiftout c_DATA, c_CLOCK, LSBFIRST, [ochar\8, blnk\1, color\3, spc\1, 0\3] return mylinex DATA 5 myliney DATA 4 myline DATA "Hello Universe!", 0