Skip to main content
Visitor II
August 29, 2007
Question

I2C troubles

  • August 29, 2007
  • 2 replies
  • 689 views
Posted on August 29, 2007 at 15:33

I2C troubles

    This topic has been closed for replies.

    2 replies

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:43

    Hi,

    I want to read 4 bytes from a I2C device using interrupts.

    After reading 4 bytes, I get continue an I2C interrupt with no event flag set (I2C_Getlastevent(I2C0) = 0).

    Any idea ?

    Kind regards

    Luc Vercruysse

    Source code in attachment.

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:43

    I don't know if you are still having this problem, but I had a similar behavior. This is the last method I call before my system really starts running.

    Code exhibits behavior

     

    void VIC_Initialize( void )

     

    {

     

    VIC_DeInit();

     

     

    VIC_Config( DMA_ITLine, VIC_IRQ , 0 );

     

    VIC_ITCmd( DMA_ITLine, ENABLE );

     

     

    VIC_Config( ENET_ITLine, VIC_IRQ, 1 );

     

    VIC_ITCmd( ENET_ITLine, ENABLE );

     

     

    VIC_Config( I2C0_ITLine, VIC_IRQ, 2 );

     

    VIC_ITCmd( I2C0_ITLine, ENABLE );

     

     

    VIC_Config( EXTIT3_ITLine, VIC_IRQ, 5 ); // IMAGER_FRAME_VALID

     

    VIC_ITCmd( EXTIT3_ITLine, ENABLE );

     

     

    VIC_Config( EXTIT1_ITLine, VIC_IRQ, 4 ); // FIFO_HALF_FULL

     

    VIC_ITCmd( EXTIT1_ITLine, ENABLE );

     

     

    VIC_Config( EXTIT2_ITLine, VIC_IRQ, 6 ); // FIFO_FULL_FLAG

     

    VIC_ITCmd( EXTIT2_ITLine, ENABLE );

     

    }

     

    Code does not exhibit behavior

     

    void VIC_Initialize( void )

     

    {

     

    VIC_DeInit();

     

     

    VIC_Config( DMA_ITLine, VIC_IRQ , 0 );

     

    VIC_ITCmd( DMA_ITLine, ENABLE );

     

     

    VIC_Config( ENET_ITLine, VIC_IRQ, 1 );

     

    VIC_ITCmd( ENET_ITLine, ENABLE );

     

     

    VIC_Config( EXTIT3_ITLine, VIC_IRQ, 5 ); // IMAGER_FRAME_VALID

     

    VIC_ITCmd( EXTIT3_ITLine, ENABLE );

     

     

    VIC_Config( EXTIT1_ITLine, VIC_IRQ, 4 ); // FIFO_HALF_FULL

     

    VIC_ITCmd( EXTIT1_ITLine, ENABLE );

     

     

    VIC_Config( EXTIT2_ITLine, VIC_IRQ, 6 ); // FIFO_FULL_FLAG

     

    VIC_ITCmd( EXTIT2_ITLine, ENABLE );

     

     

    VIC_Config( I2C0_ITLine, VIC_IRQ, 2 );

     

    VIC_ITCmd( I2C0_ITLine, ENABLE );

     

     

    }

     

    All I did would move the I2C enable to the last. And everything works correctly. I move it up and I get the interrupts non-stop.