In SX Microcontrollers, SX/B Compiler and SX-Key Tool, lboucher wrote: [quote="lboucher"] Hi All I was hoping someone could help me out with trying to control the PCA9622 with the SX28. The PCA9622 is a 16 channel LED controller and you communicate with it via I2C. I attached the datasheet. I have never used I2C or this LED controller before. I got everything wired up and spent a few hours trying to get my LED's lite up last night and it just doesn't seem to work. Hardware Setup: I am using the tssop version. I have SDA and SCL pulled high via 10k resistors like in Figure 17, and also connected to RC.0 and RC.1. I have OE pulled low via a 10K resistor, I do not have it connected to an SX pin like fig 17, its just direct to ground, does that matter? Shouldn't as far as i can tell. The A0-A6 pins are set exactly like Fig 17. which should result in an I2C address of 0010101x. I have LED8-15 hooked up, 1 led and 1 resistor Vdd=5 Due to limited space on breadboard i left LED0-7 disconnected. Firmware Side: I am following figure 14, Do pause 1000 I send a I2Cstart Then I2Csend 42 which should be correct to write to 0010101x Then I2Csend 162 which should be the correct control register setting for the sequence in Fig 14. Then i write out 16 bytes. Then send I2Cstop loop I am at work right now, will attach code when i get home. Do i have to write to MODE1 and MODE2 registers? I don't see any requirement to, if all i want to do is PWM controll of all 16 leds. I completely don't care about grouping or all call or anything like that. (Note: the one thing that is an unknown. I hand soldered the tssop package to a breakout board. So it is possible I overheated it, but i have 2 units and both won't work. I consider it slightly less likely that i damaged both units.) Also note i have quadruple checked all connections. I do see the I2Cstart/end events with a multimeter, i have no scope. Any help will be greatly appreciated. Attempt to rewrite main code piece quickly. (Can ya tell i am in a tele-con?) I2Cdatapin PIN RC.0 INPUT PULLUP (Do i need the pullup if i have external pullup, i just did this because I2CRECV example has it.) I2Cclockpin PIN RC.1 INPUT PULLUP Nak VAR Bit idx VAR Byte Start: Nak = 1 Main: pause 1000 I2CSTART I2Cdatapin I2CSEND I2Cdatapin,42,Nak 'Send address (Do i need this Nak or is that an issue?? Also i believe I remember that it was always returning 0, which i think is right?) I2CSEND I2Cdatapin,162,Nak ' Send Control Register for idx = 1 to 16 I2CSEND I2Cdatapin,128,Nak ' Light all LEDs to half brightness next I2CSTOP I2Cdatapin GOTO Main Update: Here is all the code DEVICE SX28, OSCHS2, TURBO, STACKX, OPTIONX, BOR42 FREQ 50_000_000 ID "LED16" I2CData PIN RC.0 INPUT pullup I2CClock PIN RC.1 input pullup ADC_CLK PIN RC.2 OUTPUT ADC_CS PIN RC.3 OUTPUT CH14 PIN RC.4 OUTPUT CH15 PIN RC.5 OUTPUT CH16 PIN RC.6 OUTPUT CH17 PIN RC.7 OUTPUT b_all PIN RB OUTPUT led PIN RB.1 a_all PIN RA OUTPUT brightness var byte idx VAR Byte Nak VAR BIT received var Byte I2C_TX_BYTE sub 1 I2C_Start_Led sub 0 I2C_Stop_Led sub 0 ' ========================================================================= PROGRAM Start ' ========================================================================= Start: Nak = 1 brightness = 128 low led pause 1000 Main: high led pause 1000 low led I2C_Start_Led I2C_TX_BYTE 42 '00101010 Should be address shown in figure 17 I2C_TX_BYTE 162 '10100010 Should be set to individually address all 16 led's FOR idx = 1 TO 16 I2C_TX_BYTE brightness NEXT I2C_Stop_Led inc brightness GOTO Main sub I2C_TX_BYTE i2csend I2CData,__PARAM1,Nak endsub sub I2C_Start_Led i2cstart I2CData endsub sub I2C_Stop_Led i2cstop I2CData endsub [/quote] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=440673#m440706 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2010 (http://www.dotNetBB.com)