Tool/software:
Hi,
The code has other I2C subroutines that work, but for some reason the I2C interrupts are not happening and the IRQ Handler is not entered from this subroutine.
Any ideas?
Thanks,
Dave
ps. subroutine below.
void readADC_Vz()
{
int adc_add = 0x14, adc_config = 0x80, adc_ch = 0xB0; // For ADC Channel 0, Vz.
unsigned char values[2] = "";
NVIC_EnableIRQ(I2C_BRIDGE_INST_INT_IRQN); // Enable I2C Controller Interrupt Handler
delay_cycles(1000);
values[0] = adc_ch;
values[1] = adc_config;
gI2C_Length = 2;
gI2C_Count = DL_I2C_fillControllerTXFIFO(I2C_BRIDGE_INST, &values[0], gI2C_Length); // FIFO is 8 bytes deep.
gI2cControllerStatus = I2C_STATUS_TX_STARTED;
while (!(DL_I2C_getControllerStatus(I2C_BRIDGE_INST) & DL_I2C_CONTROLLER_STATUS_IDLE));
DL_I2C_startControllerTransfer( I2C_BRIDGE_INST, adc_add, DL_I2C_CONTROLLER_DIRECTION_TX, gI2C_Length);
/* Wait until the Controller sends all bytes with no NACKs*/
while ((gI2cControllerStatus != I2C_STATUS_TX_COMPLETE) && (gI2cControllerStatus != I2C_STATUS_ERROR) ) { __WFE(); }
while (DL_I2C_getControllerStatus(I2C_BRIDGE_INST) & DL_I2C_CONTROLLER_STATUS_BUSY_BUS);
while (!( DL_I2C_getControllerStatus(I2C_BRIDGE_INST) & DL_I2C_CONTROLLER_STATUS_IDLE));
if ( gI2cControllerStatus != I2C_STATUS_ERROR) gOPUStatus = gOPUStatus & 0xFB;
else gOPUStatus = gOPUStatus | 0x04;
NVIC_DisableIRQ(I2C_BRIDGE_INST_INT_IRQN); // Disable I2C Controller Interrupt Handler
}