Welcome to the Parallax Discussion Forums, sign-up to participate.
#include "simpletools.h" #include "simplei2c.h" #define SCL 9 #define SDA 10 #define I2C_ADDR 0xe0 #define HT16K33_ADDR 0x00 #define HT16K33_OSC_ON 0x21 #define HT16K33_BLINK_CMD 0x80 #define HT16K33_BLINK_DISPLAYON 0x01 #define HT16K33_BLINK_OFF 0 #define HT16K33_BLINK_2HZ 1 #define HT16K33_BLINK_1HZ 2 #define HT16K33_BLINK_HALFHZ 3 #define HT16K33_CMD_BRIGHTNESS 0xe0 uint8_t turnOn[] = { HT16K33_OSC_ON }; uint8_t blinkOff[] = { HT16K33_BLINK_CMD | HT16K33_BLINK_DISPLAYON }; uint8_t fullBrightness[] = { HT16K33_CMD_BRIGHTNESS | 15 }; uint8_t cmd[] = { HT16K33_ADDR, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; terminal *term; int main(void) { i2c i2cBus; i2c *dev; term = simpleterm_pointer(); dev = i2c_open(&i2cBus, SCL, SDA, 0); SendCmd(dev, turnOn, sizeof(turnOn)); SendCmd(dev, blinkOff, sizeof(blinkOff)); SendCmd(dev, fullBrightness, sizeof(fullBrightness)); SendCmd(dev, cmd, sizeof(cmd)); while (1) ; return 0; } void SendCmd(i2c *dev, uint8_t *cmd, int len) { int sts; i2c_start(dev); sts = i2c_writeByte(dev, I2C_ADDR); while (--len >= 0) sts += i2c_writeByte(dev, *cmd++); i2c_stop(dev); dprint(term, "sts %d\n", sts); }
Comments
With no ACK, did you try a sweep of all i2c address, to see if any generate ACK-after-address ?
Sometimes i2c addr is not quite the same as docs...
Hollywood, CA
It's Jon or JonnyMac -- please do not call me Jonny.
Your code works fine for me...changing the bits displayed affects it as expected, too, so I know it's not just a fluke poweron glitch that makes it look like it's working.
I don't think you need pullups, though...most (or all?) of her I2C breakout boards have pullups on them, already. Have you tried without them? Also, the supply connection (+) that is 2nd in from the edge of the board is the one that works for me (don't have the schematic handy, so not sure what the leftmost one on the edge is supposed to be - it doesn't work for me...or it does, but very dimly), so that'd be another thing to check.
Cheers,
Jesse
WIP Spin drivers for various devices: lsm9ds1 IMU (SPI), Newhaven 4x20 OLED (I2C), Melexis 90621 Thermal imager (I2C), SHT3x Temp/RH (I2C), SSD1306 OLED (I2C; P1-SPIN, P2-SPIN2), AMS TCS3x7x RGB Color Sensor (I2C), MAX31856 Thermocouple Amp (SPI), BMP280 Baro. Press/Temp (I2C), Trinamic TMC2130 Stepper Driver (SPI), nRF24L01+ Driver (SPI)
My understanding is that the Vi2c pin defines the logic level and that the VCC pin powers the LEDs.
WIP Spin drivers for various devices: lsm9ds1 IMU (SPI), Newhaven 4x20 OLED (I2C), Melexis 90621 Thermal imager (I2C), SHT3x Temp/RH (I2C), SSD1306 OLED (I2C; P1-SPIN, P2-SPIN2), AMS TCS3x7x RGB Color Sensor (I2C), MAX31856 Thermocouple Amp (SPI), BMP280 Baro. Press/Temp (I2C), Trinamic TMC2130 Stepper Driver (SPI), nRF24L01+ Driver (SPI)