1
\$\begingroup\$

Many attempts to write to an i2c slave to make rgb leds light up have failed.

The hardware in question is found at: https://learn.adafruit.com/adafruit-neotrellis

There is an arduino library and a python library, but its hard to find out what i2c register does what.

My attempt, in python, is as follows:

i2c.writeto(0x2E, bytes([0x0E,0x01,0x01]), stop=True) # pin = 1 (as it is PORT A Pin 1 ??
i2c.writeto(0x2E, bytes([0x0E,0x02,0x00,0x00]), stop=True) # speed = 400khz  ?
i2c.writeto(0x2E, bytes([0x0E,0x03,0x06,0x06]), stop=True) # buff length?
i2c.writeto(0x2E, bytes([0x0E,0x04, 0x00, i, 0xff,0xff,0xff]), stop=True) # buff?
i2c.writeto(0x2E, bytes([0x0E,0x05,0x01]), stop=True) # show

The slave address is correct, and I get a response. I got my register constants from the following c-header file: https://adafruit.github.io/Adafruit_Seesaw/html/_adafruit__seesaw_8h.html

I got my info from the following document on page 30 / 38

https://cdn-learn.adafruit.com/downloads/pdf/adafruit-seesaw-atsamd09-breakout.pdf enter image description here

Here is the log of the commands from a logic analysor enter image description here

What can I do to get the leds to light up? I've used i2cdump without success, is there some brute force method to try out all combinations? What suggests do you have?

EDIT I realized that SPEED is supposed to be 8 bit not 16 bit but thats not really an issue.

\$\endgroup\$
0
\$\begingroup\$

The following code fixed things,

time.sleep(0.5)
i2c.writeto(0x2E, bytes([0x00,0x7f,0xff]), stop=True)       # ???

time.sleep(0.5)
i2c.writeto(0x2E, bytes([0x00,0x01]), stop=True)       # read id
result = bytearray(1)
time.sleep(0.5)
i2c.readfrom_into(0x2E, result)
print("module id=")
print(''.join('{:02x}'.format(x) for x in result))

i2c.writeto(0x2E, bytes([0x0E,0x02,0x01]), stop=True)  # speed = 200khz
time.sleep(0.5)
i2c.writeto(0x2E, bytes([0x0E,0x03,0x00,0x30]), stop=True)  # buff length
time.sleep(0.5)
i2c.writeto(0x2E, bytes([0x0E,0x01,0x03]), stop=True)       # pin = 3

i2c.writeto(0x2E, bytes([0x00,0x01]), stop=True)       # read id
result = bytearray(1)
i2c.readfrom_into(0x2E, result)
print("module id=")
print(''.join('{:02x}'.format(x) for x in result))


for i in range(16):
    print("writing led %d"%i)
    i2c.writeto(0x2E, bytes([0x0E,0x04, 0x00,i*3, 0x00,0xff,0x00]), stop=True)      # buff
    time.sleep(0.05)
    i2c.writeto(0x2E, bytes([0x0E,0x05]), stop=True)       # show 
    time.sleep(0.05)
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.