04.03.2013 Views

Basic Micro Studio Syntax Manual

Basic Micro Studio Syntax Manual

Basic Micro Studio Syntax Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Commands<br />

Examples<br />

Connect to the following program with the terminal window set to 9600 baud. This next example will<br />

write to the fi rst 10 locations of a 24LC512 using word sized addressing. Address is set as a word<br />

sized variable. For the Address data we use a high and low byte modifi er to load the address values<br />

from Address. For each loop we add 7 to databyte which is what we are writing to the EEPROM.<br />

The values written are 0, 7, 14, 21, 28, 35, 42, 49, 56 and 63. The program will print to the terminal<br />

window what it is writing and then what is being read. If the values above are not returned then you<br />

have a bad EEPROM or you don’t have something wired correctly (see schematic for I2COUT).<br />

databyte var byte<br />

address var Word<br />

databyte = 0<br />

address = 0<br />

pause 500<br />

main<br />

serout s_out, i9600, [13, “Writing:”,13]<br />

for address = 0 to 9<br />

i2cout p0, p1, %10100000, [address.byte1, address.byte0, databyte]<br />

Serout s_out, i9600, [dec address, “ = “, dec databyte, 13]<br />

databyte = databyte + 7<br />

pause 100<br />

Next<br />

databyte = 0<br />

address = 0<br />

pause 100<br />

serout s_out, i9600, [13, “Reading:”,13]<br />

for address = 0 to 9<br />

i2cout p0, p1, %10100000, [address.byte1,address.byte0]<br />

i2cin p0,p1, %10100000, [databyte]<br />

serout s_out, i9600, [dec address, “ = “, dec databyte, 13]<br />

pause 100<br />

next<br />

end<br />

134

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!