3.SPI/I2C Control Utility
Page.3-19
The below describes script samples(Write/Read) to control an I2C and SPI device.
(The script files are included at the bundled CD-ROM. I2C_script.txt/
SPI_script.txt)
・
Sample of I2C script
:
(Write 4bytes data(00h 01h 02h 03h) from the address of 08h of the
device at slave address 50h, and read the data to confirm the data is written properly. And also, write
data on the file, and read the data to a file to confirm the data is written. Sampling rate(frequency) is
100KHz/External power supply is 5V)
# Sample of I2C script
# ATMEL: AT24C01A Serial EEPROM Input/Output
MODE=I2C
#
I2C
mode
FILE1 "write.bin"
# data file to be sent
FILE2 "read.bin"
# file to save received data
INTERVAL=20
# Time interval between data transmission 20
μ
sec.
FREQUENCY=100
# Set sampling rate(frequency) at 100KHz.
POWER=ON5
# External power supply 5V
PULLUP=ON
# SCL,SDA line pull-up
ADDRESSMODE=7
# Address mode 7 bit
ADDRESS=50h
# Slave address 50h
#
# From here, access to a device
#
# Write 4 bytes data from address 0008h
WRITE 08h
# Write address 08h
WRITE 00h,01h,02h,03h # Write data
STOP
#
STOP
# Confirm data is written properly
# Read 4 bytes data from address 0008h
WRITE 08h
# Read address 08h
READ 4
# Read 4 bytes
STOP
#
STOP
# Read data of FILE1 from address 0008h
WRITE 08h
# Write address 08h
WRITEF
FILE1 # Write data(4 bytes of binary data at FILE1)
STOP
#
STOP
# Confirm data is written properly
# Copy data read from address 0008h onto FILE2
WRITE 08h
# Read address 08h
READF 04h
FILE2 # Copy 4 bytes read data onto FILE2
STOP
#
STOP
POWER=OFF
# External power supply 0V
END