Other Parts Discussed in Thread: TM4C129DNCPDT,
Hello friends
I am using ads7924 in my project and i2c is the link between my tm4c129Dncpdt and ADS7924,
I have configured as per the datasheet according to me.
Now the issue is I am getting the first channel value correctly on my i2c and it varies according to the input,but if I do the same thing with my second channel it is nor working.
And when I change my input to channel 1 it is effecting my channel 2 value also since I am reading only 2 channels out of four,
Below is my code on i2c. Suggest me if anything I am doing is wrong.
/**** ADC init ***/
Adc_Channel_init(0x48,0x00,0x80,1); //awake mode
Adc_Channel_init(0x48,0x12,0x1C,1); //created intrpt
Adc_Channel_init(0x48,0x00,0xC8,1);// manual scan mode
it is in 3 sec cyclic function
ROM_I2CMasterSlaveAddrSet(I2C2_BASE, slave, false);
ROM_I2CMasterDataPut(I2C2_BASE,0x82);
ROM_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_BURST_SEND_START);
while(!ROM_I2CMasterBusy(I2C2_BASE));
while(ROM_I2CMasterBusy(I2C2_BASE));
//specify that we are going to read from slave device
ROM_I2CMasterSlaveAddrSet(I2C2_BASE, slave, true);
//send control byte and read from the register we
//specified
ROM_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START);
//wait for MCU to finish transaction
while(!ROM_I2CMasterBusy(I2C2_BASE));
while(ROM_I2CMasterBusy(I2C2_BASE));
//return 1st byte pulled from the specified register
data[0] = (uint8_t)ROM_I2CMasterDataGet(I2C2_BASE);
while(ROM_I2CMasterBusy(I2C2_BASE));
ROM_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);
//wait for MCU to finish transaction
while(!ROM_I2CMasterBusy(I2C2_BASE));
while(ROM_I2CMasterBusy(I2C2_BASE));
//return 1st byte pulled from the specified register
data[1] = (uint8_t)ROM_I2CMasterDataGet(I2C2_BASE);
while(ROM_I2CMasterBusy(I2C2_BASE));
// ROM_SysCtlDelay(100);
ROM_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);
//wait for MCU to finish transaction
while(!ROM_I2CMasterBusy(I2C2_BASE));
while(ROM_I2CMasterBusy(I2C2_BASE));
//return 1st byte pulled from the specified register
data[2] = (uint8_t)ROM_I2CMasterDataGet(I2C2_BASE);
while(ROM_I2CMasterBusy(I2C2_BASE));
ROM_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);
//wait for MCU to finish transaction
while(!ROM_I2CMasterBusy(I2C2_BASE));
while(ROM_I2CMasterBusy(I2C2_BASE));
//return 1st byte pulled from the specified register
data[3] = (uint8_t)ROM_I2CMasterDataGet(I2C2_BASE);
while(ROM_I2CMasterBusy(I2C2_BASE));
ROM_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);
//wait for MCU to finish transaction
while(!ROM_I2CMasterBusy(I2C2_BASE));
while(ROM_I2CMasterBusy(I2C2_BASE));
//return 1st byte pulled from the specified register
data[4] = (uint8_t)ROM_I2CMasterDataGet(I2C2_BASE);
ROM_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);
//wait for MCU to finish transaction
while(!ROM_I2CMasterBusy(I2C2_BASE));
while(ROM_I2CMasterBusy(I2C2_BASE));
//return 1st byte pulled from the specified register
data[5] = (uint8_t)ROM_I2CMasterDataGet(I2C2_BASE);
ROM_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);
//wait for MCU to finish transaction
while(!ROM_I2CMasterBusy(I2C2_BASE));
while(ROM_I2CMasterBusy(I2C2_BASE));
//return 1st byte pulled from the specified register
data[6] = (uint8_t)ROM_I2CMasterDataGet(I2C2_BASE);
ROM_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
//wait for MCU to finish transaction
while(!ROM_I2CMasterBusy(I2C2_BASE));
while(ROM_I2CMasterBusy(I2C2_BASE));
//return 1st byte pulled from the specified register
data[7] = (uint8_t)ROM_I2CMasterDataGet(I2C2_BASE);
UARTprintf("ch1 msb %x lsb %x - ch2 msb %x lsb %x - ch3 msb %x lsb %x - ch4 msb %x lsb %x\r\n",data[0],data[1],data[2],data[3],
data[3],data[4],data[5],data[6],data[7]);
Adc_Channel_init(0x48,0x00,0xC8,1); //for multiple scan
Regards
Harish