PARAM_ERROR When i try to write I2C


#1

Hi all!, im trying to write to a IO expander with my Q2687 qith the latest OS. The slave adress is 0x3F.
I managed to Init just fine but when i try to write it return a RET PARAM Error.
The expander is the PCF8574A.

Thank u so much for advance!!!

This is my code.

bool I2C_Init(void)// *(Handler)(int))
{
TRACE((1,"[wav_I2C][I2C_Init]:Inside I2C_Init"));

I2C_MyConfig.AddrLength=ADL_BUS_I2C_ADDR_7_BITS;
I2C_MyConfig.ChipAddress=0x3F;
I2C_MyConfig.Clk_Speed=ADL_BUS_I2C_CLK_STD;
I2C_MyConfig.MasterMode=ADL_BUS_I2C_MASTER_MODE;

I2CAnswer=adl_busSubscribe(ADL_BUS_ID_I2C,1,&I2C_MyConfig);
if(I2CAnswer>0)
{
TRACE((1,"adl_busSubscribe OKAS"));
I2C_Write();
}

***********************************************************************
bool I2C_Write(void)
{
TRACE((1,"[wav_I2C][I2C_Write]:Inside I2C_Write"));

pAccessMode.Address=0;
pAccessMode.Opcode=0;

u8 I2C_DataWrite=0x04;

s32 adlbusWriteAnswer=adl_busWrite(I2CAnswer,&pAccessMode,7,&(I2C_DataWrite));

switch(adlbusWriteAnswer)
{
case OK:
TRACE((1,"adl_busWrite OKAS"));
break;

case ERROR://If a error during the operation occurs.
	TRACE((1,"adl_busWrite ERROR"));

break;

case ADL_RET_ERR_PARAM:             //If one parameter has an incorrect value.
  TRACE((1,"adl_busWrite ADL_RET_ERR_PARAM"));

break;
case ADL_RET_ERR_UNKNOWN_HDL:       //If the handle is unknown.
  TRACE((1,"adl_busWrite ADL_RET_ERR_UNKNOWN_HDL"));

break;
case ADL_RET_ERR_SERVICE_LOCKED:    //If the function was called from a low level interrupt handler in synchronous mode (the function is forbidden in this context).
  TRACE((1,"adl_busWrite ADL_RET_ERR_SERVICE_LOCKED"));
break;


}

return TRUE;
}

#2

Thanks anyway!, i managed to solved it!. It works just fine.


#3

For the benefit of others who may have similar problems, would you care to explain what it was that was wrong, and how you solved it?


#4

do you mind sharing what caused the error?
i remember looking at it, but i couldn’t find an error immediately


#5

Sure, not problem. I forget to set the lenght of the Adress and Data Buses.
This i done with the IOCTL funtion like this:

adl_busIOCtl(I2CAnswer[i],ADL_BUS_CMD_SET_ADD_SIZE,&(Device->AdressLength));
adl_busIOCtl(I2CAnswer[i],ADL_BUS_CMD_SET_DATA_SIZE,&(Device->AdressLength));

Try to be extremely careful with this because not all I2C devices works with the same length.

I hope this helps.
Best Regards,

Nicolas.