Moog Animatics SmartMotor™ Developer's Guide,Rev. L
Page 116 of 909
'''''''''''''''''''''''''''''''''''''''''''''''''
' Class 5 I2C EEPROM Test 00
' Sept 10, 2009
' I2C test for 24FC512 EEPROM on Personality Module
' Address 1010 001 x
'''''''''''''''''''''''''''''''''''''''''''''''''
SADDR1
ECHO
C0
OFF 'Turn off drive stage power
OCHN(IIC,1,N,200000,1,8,D) 'Init I/Os 4 and 5 as IIC port
PRINT(#13,"IIC Port Initialized",#13)
PRINT(#13)
END
C100 'Write variable a at pointer p
al[0]=a
al[1]=p
PRINT(#13)
PRINT("Load ",al[0]," at pos ",p,#13)
PRINT1(IIS,#160,#ab[5],#ab[4],#ab[3],#ab[2],#ab[1],#ab[0],IIP)
PRINT("Load bytes: ",ab[3],", ",ab[2],", ",ab[1],", ",ab[0],#13)
PRINT(#13)
RETURN
C200 'Read into variable a at pointer p
al[1]=p
PRINT1(IIS,#160,#ab[5],#ab[4],IIP) 'Write memory pointer
WAIT=1 'Must have small wait to give the write time it needs
PRINT1(IIS,#161,IIG4,IIP) 'Setup to read four bytes
WAIT=1 'Must have small wait to give the write time it needs
ab[3]=GETCHR1
ab[2]=GETCHR1
ab[1]=GETCHR1
ab[0]=GETCHR1
a=al[0]
PRINT(#13)
PRINT("Read bytes: ",ab[3],", ",ab[2],", ",ab[1],", ",ab[0],#13)
PRINT("Read ",a," at pos ",p,#13)
PRINT(#13)
RETURN
The following are related commands. For more details on these commands, see Part 2:
SmartMotor Command Reference on page 238.
Part 1: Programming: I²C Communications (D-Style Motors)