Bus Write Success but data not sent


#1

Hi all,

I am trying to write data to the I2C. The adl_buswrite returns success but there is no data sent on the bus. Meanwhile when i try to read data, i am able to get the data.

Could anyone kindly help me in sorting out the problem.

#include "adl_global.h"

/***************************************************************************/
/*  Mandatory variables                                                    */
/*-------------------------------------------------------------------------*/
/*  wm_apmCustomStackSize                                                  */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
const u16 wm_apmCustomStackSize = 1024;

s32 I2C_ADS112_Handle;
static adl_tmr_t *ADC_Tmr;
adl_busAccess_t iicBus_Access = { 0, 0 };


u32 I2C_ADS112_Init ( void );
void ADC_Handler(u8 id,void *Context);
void Write_Data(u8 x);
void Read_Value(u8 id,void *Context);
/***************************************************************************/
/*  Function   : adl_main                                                  */
/***************************************************************************/
void adl_main(adl_InitType_e adlInitType)
{
    adl_atSendResponse(ADL_AT_RSP,"\r\n I2C Testing\r\n");

    if ( I2C_ADS112_Init() ){
        adl_atSendResponse(ADL_AT_RSP,"\r\n I2C Subscribed\r\n");
        ADC_Tmr=adl_tmrSubscribe(TRUE,100,ADL_TMR_TYPE_100MS,ADC_Handler);
    }
    else{
    	adl_atSendResponse(ADL_AT_RSP,"\r\n I2C Subscribe Failed\r\n");
    }
}


/***************************************************************************/
/*  Function   : I2C_ADS112_Init		                                   */
/***************************************************************************/
u32 I2C_ADS112_Init ( void )
{
    u32 length = 8;

    adl_busI2CSettings_t I2CSettings =     {
        (0x90>>1),                // ChipAddress
        ADL_BUS_I2C_CLK_FAST,     // Clk_Speed
        ADL_BUS_I2C_ADDR_7_BITS,
        ADL_BUS_I2C_MASTER_MODE
    };

    /* Open I2C bus */
    I2C_ADS112_Handle = adl_busSubscribe (
    		ADL_BUS_I2C,
            1,
            &I2CSettings );

	adl_busIOCtl(I2C_ADS112_Handle, ADL_BUS_CMD_SET_ADD_SIZE, &length);
	return I2C_ADS112_Handle;
}

/***************************************************************************/
/*  Function   : ADC_Handler										       */
/*-------------------------------------------------------------------------*/
/*  Object     : This timer is used to read the ADC Values				   */
/*					every 10 Seconds to Server 							   */
/***************************************************************************/
void ADC_Handler(u8 id,void *Context)
{
	u8 Data;

	Data=0x01;
	Write_Data(Data);
	Data=0xC1;
	Write_Data(Data);
	Data=0xE0;
	Write_Data(Data);

	/*Place the settings info in the Low Thresh-hold Register*/
	Data=0x02;
	Write_Data(Data);
	Data=0x00;
	Write_Data(Data);
	Data=0x00;
	Write_Data(Data);

	/*Place the settings info in the High Thresh-hold Register*/
	Data=0x03;
	Write_Data(Data);
	Data=0xFF;
	Write_Data(Data);
	Data=0xFF;
	Write_Data(Data);

	adl_tmrSubscribe(FALSE,20,ADL_TMR_TYPE_100MS,Read_Value);
}


/***************************************************************************/
/*  Function   : Write_Data											       */
/*-------------------------------------------------------------------------*/
/*  Object     : Writes the data to the I2C Bus							   */
/***************************************************************************/
void Write_Data(u8 x)
{
	u8 data;
	data = x;
	iicBus_Access.Address = ((u32)0x90)<<24;
	if(adl_busWrite(I2C_ADS112_Handle,&iicBus_Access,1,(void*)&data)==OK){
		//Do Nothing
	}else{
		adl_atSendResponse(ADL_AT_RSP,"\r\n Write Error\n");
	}
}


/***************************************************************************/
/*  Function   : Read_Value											       */
/*-------------------------------------------------------------------------*/
/*  Object     : Reads Value from a register							   */
/***************************************************************************/
void Read_Value(u8 id,void *Context)
{
	u16 Register_Val=0;
	char Values[2];
	u8 Data;
	Data = 0x02;
	adl_atSendResponse(ADL_AT_RSP,"\r\n Going to Read\r\n");
	Write_Data(Data);
	char Sting_Val[10];

	iicBus_Access.Address = ((u32)0x91)<<24;
	//iicBus_Access.Address |= 0x80000000;

	if(adl_busRead(I2C_ADS112_Handle,&iicBus_Access,2,(void*)&Register_Val)==OK){
		Values[1]=(Register_Val & 0xFF);
		Values[0]=(Register_Val>>8);
		wm_sprintf(Sting_Val,"%x%x",Values[1],Values[0]);
		//adl_atSendResponse(ADL_AT_RSP,"\r\n Read1 Success\r\n");
		adl_atSendResponse(ADL_AT_RSP,Sting_Val);
	}else{
		adl_atSendResponse(ADL_AT_RSP,"\r\n Read Error\n");
	}
}

Thanks & Regards,
Rajamanickem. S


#2

How have you determined that :question: