Commands Examples Connect to the following program with the terminal window set to 9600 baud. This next example will write to the fi rst 10 locations of a 24LC512 using word sized addressing. Address is set as a word sized variable. For the Address data we use a high and low byte modifi er to load the address values from Address. For each loop we add 7 to databyte which is what we are writing to the EEPROM. The values written are 0, 7, 14, 21, 28, 35, 42, 49, 56 and 63. The program will print to the terminal window what it is writing and then what is being read. If the values above are not returned then you have a bad EEPROM or you don’t have something wired correctly (see schematic for I2COUT). databyte var byte address var Word databyte = 0 address = 0 pause 500 main serout s_out, i9600, [13, “Writing:”,13] for address = 0 to 9 i2cout p0, p1, %10100000, [address.byte1, address.byte0, databyte] Serout s_out, i9600, [dec address, “ = “, dec databyte, 13] databyte = databyte + 7 pause 100 Next databyte = 0 address = 0 pause 100 serout s_out, i9600, [13, “Reading:”,13] for address = 0 to 9 i2cout p0, p1, %10100000, [address.byte1,address.byte0] i2cin p0,p1, %10100000, [databyte] serout s_out, i9600, [dec address, “ = “, dec databyte, 13] pause 100 next end 134
Commands Examples Connect to the following program with the terminal window set to 9600 baud. The 24LC08 has 4 pages of 255 bytes each. The example will write to the fi rst 10 memory locations of all 4 pages then read back and print to the terminal window. Each page is accessed with A0,A1 and A2 internally. So the control bits change for each page. databyte var byte address var Byte databyte = 10 address = 0 pause 500 main serout s_out, i9600, [13, “Writing:”,13] for address = 0 to 9 ;increment through the fi rst 10 locations i2cout p0, p1, %10100000, [address, databyte] ;page 1 i2cout p0, p1, %10100010, [address, databyte] ;page 2 i2cout p0, p1, %10100100, [address, databyte] ;page 3 i2cout p0, p1, %10100110, [address, databyte] ;page 4 ;lets see what we are writting to each address on each page serout s_out, i9600, [“Page 1 to 4-> “,dec address,” = “,dec | databyte, 13] databyte = databyte + 10 pause 100 Next databyte = 0 address = 0 serout s_out, i9600, [13, “Reading:”,13] for address = 0 to 9 ;increment through the fi rst 10 locations i2cout p0, p1, %10100000, [address] ;page 1 i2cin p0,p1, %10100000, [databyte] i2cout p0, p1, %10100010, [address] ;page 2 i2cin p0,p1, %10100010, [databyte] i2cout p0, p1, %10100100, [address] ;page 3 i2cin p0,p1, %10100100, [databyte] i2cout p0, p1, %10101100, [address] ;page 4 i2cin p0,p1, %10101100, [databyte] ;lets read and print each address of each page. serout s_out, i9600, [“Page 1 to 4-> “,dec address,” = “,dec | databyte, 13] pause 100 next end 135
- Page 1 and 2:
Basic Micro Studio Syntax Manual Ba
- Page 3 and 4:
Introduction ......................
- Page 5 and 6:
FCOSH .............................
- Page 7 and 8:
Introduction Introduction Welcome t
- Page 9 and 10:
Introduction Hardware Introduction
- Page 11 and 12:
Hardware Nano 8 The BasicATOM Nano
- Page 13 and 14:
Hardware Nano 40 The BasicATOM Nano
- Page 15 and 16:
Hardware Nano 40X The BasicATOM Nan
- Page 17 and 18:
Hardware BasicATOM 40m The BasicATO
- Page 19 and 20:
Hardware BasicATOM Pro 28m The Basi
- Page 21 and 22:
Quick Start Guide The next few page
- Page 23 and 24:
Quick Start Quick Start Before writ
- Page 25 and 26:
Quick Start 1. Microcontroller Fami
- Page 27 and 28:
Quick Start If the program is corre
- Page 29 and 30:
Quick Start Terminal Window Connect
- Page 31 and 32:
Variables 31 Variables
- Page 33 and 34:
Defi ning Variables Variables are d
- Page 35 and 36:
Out of Range When declaring variabl
- Page 37 and 38:
Constants Structure - Constants Con
- Page 39 and 40:
Pins and Ports Structure - Pins and
- Page 41 and 42:
Direction Variables The DIR variabl
- Page 43 and 44:
Math 43 Math
- Page 45 and 46:
Operators Operator Description Stru
- Page 47 and 48:
- (Negative) ABS Signs an expressio
- Page 49 and 50:
DCD NCD Structure - Math DCD is sim
- Page 51 and 52:
BIN2BCD, BCD2BIN RANDOM Structure -
- Page 53 and 54:
Division (/) Structure - Math Divid
- Page 55 and 56:
MAX MIN DIG REV The MAX function re
- Page 57 and 58:
AND (&) OR ( | ) Structure - Math T
- Page 59 and 60:
XOR NOT (^/) Structure - Math The X
- Page 61 and 62:
OR XOR Structure - Math The OR oper
- Page 63 and 64:
Floating Point Math TOINT TOFLOAT S
- Page 65 and 66:
FASIN FACOS FATAN FLN Structure - M
- Page 67 and 68:
Structure - Math Hyperbolic Functio
- Page 69 and 70:
Modifi ers In MBasic, all values ar
- Page 71 and 72:
DEC DEC{#max} expression{\#min} #ma
- Page 73 and 74:
HEX HEX{#max} expression{\#min} #ma
- Page 75 and 76:
IHEX IHEX{#max} expression{\#min} #
- Page 77 and 78:
BIN BIN{#max} expression{\#min} #ma
- Page 79 and 80:
IBIN IBIN{#max} expression{\#min} #
- Page 81 and 82:
REAL REAL{#maxint} expression{\#max
- Page 83 and 84: Command Reference 83 Command Refere
- Page 85 and 86: ADIN Syntax adin pin, result Comman
- Page 87 and 88: ADIN16 Syntax adin16 pin, result
- Page 89 and 90: Commands Examples Connect to the fo
- Page 91 and 92: Commands The BUTTON command must be
- Page 93 and 94: CLEAR Syntax clear Supported • BA
- Page 95 and 96: DEBUG Syntax debug [{modifi ers}dat
- Page 97 and 98: DEBUGIN Syntax debugin [{modifi ers
- Page 99 and 100: DO - WHILE Syntax do program statem
- Page 101 and 102: DTMFOUT Syntax dtmfout pin,{ontime,
- Page 103 and 104: DTMFOUT2 Syntax dtmfout2 Lpin\Hpin,
- Page 105 and 106: END Syntax end Supported • BA - s
- Page 107 and 108: FATAN2 Syntax fatan2 xval\yval,vari
- Page 109 and 110: Commands Example The example below
- Page 111 and 112: Commands The next program will incr
- Page 113 and 114: Commands Example The program below
- Page 115 and 116: HIGH Syntax high pin • PIN - is a
- Page 117 and 118: Commands The rate of the high side
- Page 119 and 120: Commands SETHSERIAL MBasic must cre
- Page 121 and 122: BAP Error BAP40 Error BA Error BAN
- Page 123 and 124: HSERVO Syntax hservo [pin\pos\spd,
- Page 125 and 126: IF...THEN...ELSEIF...ELSE...ENDIF S
- Page 127 and 128: Commands Advance Arguments Now that
- Page 129 and 130: INPUT Syntax input pin Commands •
- Page 131 and 132: Commands Schematic The following sc
- Page 133: I2CIN Syntax i2cin sda, scl, contro
- Page 137 and 138: Commands Schematic The schematic sh
- Page 139 and 140: LCD Command Table Command Value Fun
- Page 141 and 142: Commands Custom Characters Most HD4
- Page 143 and 144: LCDREAD Syntax lcdread RS\ E\ D7\ D
- Page 145 and 146: LOOKDOWN Syntax lookdown value,{ope
- Page 147 and 148: LOOKUP Syntax lookup index,[list],t
- Page 149 and 150: LOW Syntax low pin • Pin - is a v
- Page 151 and 152: OWIN Syntax owin pin,mode,{FailLabe
- Page 153 and 154: OWOUT Syntax owout pin,mode,{NCLabe
- Page 155 and 156: OUTPUT Syntax output pin • Pin -
- Page 157 and 158: PAUSEUS Syntax pauseus time Command
- Page 159 and 160: ;AtomPro pauseclk example Serout s_
- Page 161 and 162: Schematics Connect a momentary swit
- Page 163 and 164: Commands Examples The example progr
- Page 165 and 166: Commands Duty Cycle The following c
- Page 167 and 168: Commands Schematic The schematic ca
- Page 169 and 170: READ Syntax read address, databyte
- Page 171 and 172: REPEAT - UNTIL Syntax repeat progra
- Page 173 and 174: Commands Example The program below
- Page 175 and 176: SERIN Syntax serin rxpin{\fpin},bau
- Page 177 and 178: Commands Parity Parity is used to d
- Page 179 and 180: Commands In other cases you may wan
- Page 181 and 182: Commands All of the Basic Micro mod
- Page 183 and 184: Commands Limitations The Nano maxim
- Page 185 and 186:
SERVO Syntax servo pin,pos{,repeat}
- Page 187 and 188:
Speeds Processor Mode 0-4 Mode 5-7
- Page 189 and 190:
;[PS2 Controller Constants] DAT con
- Page 191 and 192:
SHIFTOUT Syntax shiftout dpin,cpin,
- Page 193 and 194:
Commands Notes 1. SHIFTIN and SHIFT
- Page 195 and 196:
SOUND Syntax sound pin, [duration\n
- Page 197 and 198:
SOUND2 Syntax sound2 pin1\pin2,[dur
- Page 199 and 200:
SWAP Syntax swap variable1, variabl
- Page 201 and 202:
WHILE - WEND Syntax while condition
- Page 203 and 204:
WRITE Syntax write address, data
- Page 205 and 206:
Interrupts 205 Interrupts
- Page 207 and 208:
RESUME resume Interrupts This comma
- Page 209 and 210:
BAP ONE/24/28 Only Interrupt Types
- Page 211 and 212:
Basic Stamp Conversion Basic Stamp
- Page 213 and 214:
INPUT The INPUT command functions t
- Page 215 and 216:
Basic Stamp Conversion POLLWAIT The
- Page 217 and 218:
Compiler Directives 217 Compiler Di
- Page 219 and 220:
#IF .. #ENDIF #IF expression option
- Page 221 and 222:
#ELSEIFDEF, #ELSEIFNDEF Equivalents
- Page 223 and 224:
Reserved Words Reserved Words The f
- Page 225 and 226:
Reserved Words Name Name Name Name
- Page 227 and 228:
Reserved Words Name Name Name Name
- Page 229 and 230:
ASCII Table 229 ASCII Table
- Page 231:
Basicmicro.com (c) 2011 Version 2.1