cancel
Showing results for 
Search instead for 
Did you mean: 

I2C troubles

craig239955_st
Associate II
Posted on August 29, 2007 at 15:33

I2C troubles

2 REPLIES 2
craig239955_st
Associate II
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.

sarao
Associate II
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.