![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
NicolasC
Joined: 14 Sep 2006 Posts: 27
|
MAX6956 : Led driver troubles |
Posted: Sun Jan 14, 2007 3:55 pm |
|
|
Hi,
I have trouble controlling a MAX6956 as led driver.
When port is configured as GPIO I have no problems for reading and writing ports.
But when configured as led driver I can't sink any current. I replace the led with a pullup resistor but still get the same behaviour.
With GPIO output I can light the led (but of course no current control).
No success either with "Display test" function.
Here is my code. Any hint welcome.
Code: |
enum keypad_state {
IDLE,
OUTPUT_COL
};
#define Port_12_19 0x4C
#define _TEMPO_ 0xFFFF
#define WRITE_ADDR (device_address<<1) & 0xFE
#define READ_ADDR (device_address<<1) | 0x01
int device_address;
typedef int key_cde;
static int16 tempo = _TEMPO_;
static keypad_state mfd_state = IDLE; //machine state for port operation
void write_port(int PortNum, Data)
{
disable_interrupts(GLOBAL);
i2c_start();
i2c_write( WRITE_ADDR );
i2c_write( PortNum );
i2c_write( Data );
i2c_stop();
enable_interrupts(GLOBAL);
}
// Initialise the I2C bus and config register
void mfd_init(int addr )
{
int i;
printf("\r\nI2C init");
addr+= 0x40; //MAX6956 addresses take the form 100xxxx
device_address = addr; //where xxxx is the user-selected address 0-15.
i2c_start();
i2c_write( WRITE_ADDR );
i2c_write( 0x02 ); //Select @02 : Global current config register
i2c_write( 0x0F ); //Set 12mA
i2c_write( 0x00 ); //@03 empty byte
i2c_write( 0x01 ); //@04 Set config register (Transition disable, Global current, no shutdown)
i2c_stop();
//configure port 12 to 22
i2c_start();
i2c_write( WRITE_ADDR );
i2c_write( 0x0B ); //select @0x0B : P15, P14, P13, P12 port config register
i2c_write( 0x00 ); //@0x0B : set Led driver (0x00) // GPIO Output(0x55)
i2c_write( 0x00 ); //@0x0C : P19, P18, P17, P16 : set Led driver (0x00) // set GPIO Output
i2c_stop();
/*
//configure test LED
i2c_start();
i2c_write( WRITE_ADDR );
i2c_write( 0x07 ); //select @0x0B : P15, P14, P13, P12 port config register
i2c_write( 0x01 ); //@0x07 : set Display test
i2c_stop();
*/
mfd_state = OUTPUT_COL;
printf("\r\nI2C init done");
}
int mfd_task(void){
static int is;
switch (mfd_state) {
case IDLE :
mfd_init(0);
break;
default:
if (! --tempo) {
tempo = _TEMPO_;
if ( is ) {
getc();
write_port( Port_12_19, 0x00 /*0b01010101*/ );
is = 0;
printf("\n\rLeds on");
} else {
getc();
write_port( Port_12_19, 0xFF /*0b10101010*/ );
is = 1;
printf("\n\rLeds off");
}
return 1;
} else
return 0;
}
}
|
Regards |
|
![](templates/subSilver/images/spacer.gif) |
Kenny
Joined: 07 Sep 2003 Posts: 173 Location: Australia
|
|
Posted: Sun Jan 14, 2007 6:59 pm |
|
|
I haven't used this chip, but noticed the following:
Do you have the recommended 39k resistor connected from ISET to GND to set the maximum segment current?
If so, I think that 0x07 would the value for setting 12mA for all leds.
Also, I think that 0xFF would turn on the leds in the write_port() function. |
|
![](templates/subSilver/images/spacer.gif) |
NicolasC
Joined: 14 Sep 2006 Posts: 27
|
|
Posted: Mon Jan 15, 2007 1:07 am |
|
|
Yes 39k... But connected to the VCC. ... And I was looking for software problem.
Quote: | If so, I think that 0x07 would the value for setting 12mA for all leds. | You 're right : I've tried different values and now the comment is outdated.
Thanks for your help. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|