This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSPM0G3107-Q1: I2Q IRQ not enabled even though code enables it

Part Number: MSPM0G3107-Q1


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
}

  • Hi,

    This subroutine is called from within a Timer0 IRQ.

    When I call it from main(), the I2C IRQ functions.

    Apparently when inside an IRQ other interrupts are masked. Is there a way around that?

    Thanks,

    dave

  • In an ISR all interrupts of the same or lower priority (higher number) are masked. At reset, all interrupts have the same priority (0 or 1 I think; I don't have my materials here) so the result is that all other interrupts are masked.

    You can try setting the priority for the timer to something like 2 or 3 with NVIC_SetPriority(<IRQn>,2), leaving the I2C interrupt alone. That does mean that any other interrupts can also preempt your timer ISR, but maybe that's OK.

  • Thanks Bruce.

    To play it safe, I think I'll set a flag in the ISR and run the I2C activity out of the main loop.

    Thanks,

    dave