Get BlinkM version or address with Basic Stamp
I am having trouble retrieving the BlinkM address and version info using a Basic Stamp:
The address comes back as 255.
Sending commands work fine.
BlinkMAddress: 'doesn't work
GOSUB I2C_Start
I2C_data = DeviceAddr << 1 ' shift left because address is upper 7 bits
GOSUB I2C_Send
I2C_data = "a"
GOSUB I2C_Send
IF (I2C_ack = Nak) THEN BlinkMAddress ' wait until not busy
I2C_ack = Nak
I2C_data = 0
SHIFTIN SDA, SCL, MSBPRE, [I2C_data\8]
SHIFTOUT SDA, SCL, LSBFIRST, [I2C_ack\1] ' send ack or nak
DEBUG "Address: ", DEC I2C_data, CR
GOSUB I2C_Stop
PAUSE 1
RETURN
'Send Address or Data Procedure
I2C_Send:
SHIFTOUT SDA, SCL, MSBFIRST, [I2C_data] '[I2C_data\8] 'Send Byte To Device
SHIFTIN SDA, SCL, MSBPRE, [I2C_ack\1] '[I2C_ack\1] ' Get Acknowledge Bit
RETURN
' -----[ Low Level I2C Subroutines]----------------------------------------
I2C_Start: ' I2C Start Bit Sequence
INPUT SDA
INPUT SCL
LOW SDA ' SDA --> Low While SCL High
RETURN
I2C_Stop: ' I2C Stop Bit Sequence
LOW SDA
INPUT SCL
INPUT SDA ' SDA --> High While SCL High
RETURN
The address comes back as 255.
Sending commands work fine.
BlinkMAddress: 'doesn't work
GOSUB I2C_Start
I2C_data = DeviceAddr << 1 ' shift left because address is upper 7 bits
GOSUB I2C_Send
I2C_data = "a"
GOSUB I2C_Send
IF (I2C_ack = Nak) THEN BlinkMAddress ' wait until not busy
I2C_ack = Nak
I2C_data = 0
SHIFTIN SDA, SCL, MSBPRE, [I2C_data\8]
SHIFTOUT SDA, SCL, LSBFIRST, [I2C_ack\1] ' send ack or nak
DEBUG "Address: ", DEC I2C_data, CR
GOSUB I2C_Stop
PAUSE 1
RETURN
'Send Address or Data Procedure
I2C_Send:
SHIFTOUT SDA, SCL, MSBFIRST, [I2C_data] '[I2C_data\8] 'Send Byte To Device
SHIFTIN SDA, SCL, MSBPRE, [I2C_ack\1] '[I2C_ack\1] ' Get Acknowledge Bit
RETURN
' -----[ Low Level I2C Subroutines]----------------------------------------
I2C_Start: ' I2C Start Bit Sequence
INPUT SDA
INPUT SCL
LOW SDA ' SDA --> Low While SCL High
RETURN
I2C_Stop: ' I2C Stop Bit Sequence
LOW SDA
INPUT SCL
INPUT SDA ' SDA --> High While SCL High
RETURN
1
person has this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
Create a customer community for your own organization
Plans starting at $19/month
Loading Profile...


