AnsweredAssumed Answered

STM32F030 I2C1 interrupt not firing

Question asked by Conover.John on Nov 9, 2016
Latest reply on Nov 10, 2016 by waclawek.jan
Hi,

     I'm trying to move my I2C1 code over from polling based functions to interrupt based(we use the standard peripheral libs.) I must be missing some basic configuration as the interrupt will not fire. The code below shows my configuration and I2C transmit/IRQ functionality. Am I missing a config piece or maybe an configuration ordering issue?

Thanks,
     John C.
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);
 
    // I2C1 channel init. LCD and EEPROM chip are on this bus.
    I2C_DeInit(I2C1);
    I2C_StructInit(&I2C_InitStruct);
    I2C_InitStruct.I2C_Ack              = I2C_Ack_Enable;
    I2C_InitStruct.I2C_AcknowledgedAddress= I2C_AcknowledgedAddress_7bit;
    I2C_InitStruct.I2C_AnalogFilter         = I2C_AnalogFilter_Enable;
    I2C_InitStruct.I2C_DigitalFilter            = 0;
    I2C_InitStruct.I2C_Mode             = I2C_Mode_I2C;
    I2C_InitStruct.I2C_OwnAddress1      = 0;
    //I2C_InitStruct.I2C_Timing         = 0xB0420F13; // 100Khz I2C clock with main @ 48Mhz
    I2C_InitStruct.I2C_Timing           = 0x50330309; // 400Khz I2C clock with main @ 48Mhz
    I2C_Init(I2C1, &I2C_InitStruct);
 
    NVIC_InitStructure.NVIC_IRQChannel      = I2C1_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPriority  = 0x00;
    NVIC_InitStructure.NVIC_IRQChannelCmd   = ENABLE;
     NVIC_Init(&NVIC_InitStructure);
 
    NVIC_EnableIRQ(I2C1_IRQn);
    NVIC_SetPriority(I2C1_IRQn,0);
 
 
    // Start of I2C transmit
    I2C_ITConfig(I2C1, I2C_IT_TCI, ENABLE);
 
    // I have tried each of these and none seem to get the interrupt to fire.
    I2C_TransferHandling(I2C1, 0x7C, SendCnt, I2C_Reload_Mode, I2C_Generate_Start_Write);
 
    I2C_TransferHandling(I2C1, 0x7C, SendCnt, I2C_Reload_Mode, I2C_Generate_Start_Write);
 
    I2C_TransferHandling(I2C1, 0x7C, SendCnt, I2C_AutoEnd_Mode, I2C_Generate_Start_Write);
 
    I2C_TransferHandling(I2C1,  0x7C, SendCnt, I2C_AutoEnd_Mode, I2C_Generate_Stop);
 
void __attribute__((optimize("O0")))  I2C1_IRQHandler(void)
{
    // See if we have received a Transmit complete
    if(I2C_GetITStatus(I2C1, I2C_IT_TCR) != RESET)
    {
    }
}

Outcomes