I2C Bus write return -1


Hi All,

I am trying to work on i2c bus of wavecom (Q24 Plus) with PCA9502 I/O expander ( nxp.com/acrobat_download/dat … 9502_3.pdf ) which has i2c/spi inerface.

Bus Enable always sucuss and bus write function always return -1 (BUS_MODE_UNKNOWN_TYPE)

Could any one help to find out the problem.

Thanks in advance.


Hi venkat,
Can you show the code? All i2c parameters config right?


Hi trthaithong,

I here by post my code as on your request.

void iic_Init( u8 id )
    adl_atSendResponse(ADL_AT_UNS,"\r\n I'm in iic_Init\r\n");
    /* i2c bus initialization  */
    // slave address 0x92
    iic_BusHandle =  adl_busSubscribe( ADL_BUS_TYPE_I2C_HARD|0x49,   ADL_BUS_I2C_HARD_CLK_STD );

   if( iic_BusHandle == ADL_RET_ERR_PARAM )
       adl_atSendResponse(ADL_AT_UNS,"\r\n ERROR : ONE OF THE PARAMETER HAS INCORRECT VALUE \r\n" );
  else if( iic_BusHandle == ADL_RET_ERR_ALREADY_SUBSCRIBED )
      adl_atSendResponse(ADL_AT_UNS,"\r\n ERROR : IIC BUS ALREADY SUBSCRIBED \r\n" ); 
  else if( iic_BusHandle >= 0 )
      adl_atSendResponse(ADL_AT_UNS,"\r\n IIC BUS ENABLE SUCCESS\r\n" );
      pca_Config( 1 );
     adl_atSendResponse(ADL_AT_UNS,"\r\n IIC BUS ENABLE FAIL\r\n" );

void pca_Config( u8 id )
    s8 iic_BusWrHandle;
    char tempBuf[100];
    // IOControl register address 0x0E
    iic_BusWrHandle = adl_busWrite( (u8) iic_BusHandle, (adl_busAccess_t *) NULL, (u32)  Data_Len, (void *) 0x07 );
    // iic_BusWrHandle = adl_busWrite( (u8) iic_BusHandle, (adl_busAccess_t *) NULL, (u32)  Data_Len, (void *) 0x0E );

    if( iic_BusWrHandle == ADL_RET_ERR_UNKNOWN_HDL )
        adl_atSendResponse(ADL_AT_UNS,"\r\n ERROR : IIC HANDLE PROVIDED AS UNKNOWN \r\n");
    else if( iic_BusWrHandle == ADL_RET_ERR_PARAM )
        adl_atSendResponse(ADL_AT_UNS,"\r\n ERROE : PARAMETER HAS INCORRECT VALUE \r\n");
    else if( iic_BusWrHandle == OK )
       adl_atSendResponse(ADL_AT_UNS,"\r\n SUCCESS : IIC BUS WRITE SUCCESS \r\n");     
        sprintf( tempBuf, "\r\n ERROR NUMBER : %d \r\n",iic_BusWrHandle );
        adl_atSendResponse(ADL_AT_UNS,"\r\n ERROR : IIC BUS WRITE UNKNOWN ERROR \r\n");

For above code, i had the messages as below

I’m in iic_Init




Please let me know any problem with my config code…

Thanks & regards


Hi venkat,

  1. For this line:
    iic_BusWrHandle = adl_busWrite( (u8) iic_BusHandle, (adl_busAccess_t *) NULL, (u32) Data_Len, (void *) 0x07 );
    0x07 would be treated as memory address
    If you wanted to write one byte (assume you already set “Data_Len” to 1)
    Data_Byte = 0x07;
    iic_BusWrHandle = adl_busWrite( (u8) iic_BusHandle, (adl_busAccess_t *) NULL, (u32) Data_Len, (void *) &Data_Byte );

  2. But this does not seem to correspond to the error -1, which is “BUS_MODE_UNKNOWN_TYPE” – are you using a very old version of Open AT® that does not have I2C hard?


Hi trthaithong,

Currently i am using open AT OS v03.12 and open AT software tool v03.13.

  1. I don’t know weather my OPEN AT version supporting i2c hard bus or not?

  2. Which Open AT version support i2c hard bus?



Hi venkat,
You are already dev on the OS have i2c hard (OS v3.12). It is because of another reason.


Hi trthaithong,

Thanks for ur reply.

I have tested my hardware by use of scope. There SDA and SCL lines seems always
high. There no pluses observed!!! :angry:

Also adl_busSubscribe() function always success, i mean if i laod the slave address as 0x01,0x02… its success. How? :question:

I am excepting a document about i2c bus of wavecom.

Could you please help to find out this problem.

Thanks & Regards,


I suppose BusSubscribe only allocates the memory and initialises it with the provided settings.
bus_write/read commands (and their variations) are the only commands that actually output to the bus.

The only way busSubscribe would fail would be if it can’t allocate the resources it needs.