I2C FLT being set

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

I2C FLT being set

1,287 次查看
martindusek
Contributor V

I have an I2C slave on KL02. It communicates with master well however after some time, FLT in I2C->FLT is set to number 16 and I2C communication freezes as slave holds lines low. FLT is set autonomously by I2C module, I don't write to FLT in my program (nor accidentaly).

Can somebody explain how can that happen?

标签 (1)
标记 (2)
0 项奖励
7 回复数

814 次查看
adriancano
NXP Employee
NXP Employee

Hi,

This is a weird behavior of the I2C module; the FLT field of the I2Cx_FLT register is directly  bound to the I2C frequency. Which is the frequency you are configuring your I2C module?

The I2C module have a frequency up to CLKBUS/20 , probably if it is not like this the Programmable input glitch filter could be behave in an odd way.

Hope this helps,

Regards,

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. It would be nice!

-----------------------------------------------------------------------------------------------------------------------

0 项奖励

814 次查看
martindusek
Contributor V

I'm not configuring IIC baud rate on my device at all because it is a slave device. Anything else?

0 项奖励

814 次查看
perlam_i_au
Senior Contributor I

Could you please share your initialization routine? I would like to see your configuration.

This is a very weird error but I think this could be caused by something missing on configuration or even in something small on your functional code (forgot to clear a flag or something) :/

I will be glad to take a look on your code.

0 项奖励

814 次查看
martindusek
Contributor V

This is my IIC slave driver (sorry, I can't see any option to format the text as source code). I don't proces IIC events in ISR. When an IIC interrupt occurs, I disable it at NVIC and later proces the interrupt in my main program (IicSlaveExecute()). Calls IicSlaveAddressed, IicSlaveStopped, IicSlaveByteGet, IicSlaveByteProcess are callbacks to my application level.

Macros Flag(), ArbitrationLost(), ... are abbreviations for IIC->S & I2C_S_IICIF_MASK, IIC->S & I2C_S_ARBL_MASK, ...

void IicSlaveInit( void)
// Initialize bus
{
   SIM->SCGC4 |= SIM_SCGC4_I2C0_MASK
   PinFunction(IIC_SLAVE_SDA_PIN, IIC_SLAVE_SDA_PIN_FUNCTION);
   PinFunction(IIC_SLAVE_SCL_PIN, IIC_SLAVE_SCL_PIN_FUNCTION);
   IIC->C1 = 0;
  
CpuIrqAttach(I2C0_IRQn, 0, I2C0_IRQHandler);
   CpuIrqEnable( I2C0_IRQn);

   IIC->A1 = IIC_SLAVE_ADDRESS;
   IIC->C1 = I2C_C1_IICEN_MASK | I2C_C1_IICIE_MASK; | I2C_C1_WUEN_MASK;
   IIC->FLT |= I2C_FLT_STOPIE_MASK;
} // IicSlaveInit

void IicSlaveExecute( void)
// Execute
{
byte Data;
   if(!Flag()) {
      return;
   }

   if(IIC->FLT & 16) { // if I don't
      IIC->FLT |= 16;
      ClearFlag();
   } else if(ArbitrationLost()) {
      ArbitrationLostClear();
      ClearFlag();
   } else if(StopFlag()) {
      ClearStopFlag();
      ClearFlag();
      Acknowledge();
      SetReceiveMode();
      Read();
      IicSlaveStopped();
   } else if(Addressed()) {
      ClearFlag();
      IicSlaveAddressed( !ReadWrite());
      Acknowledge();

      if(ReadWrite()) {
         SetTransmitMode();
         if(!IicSlaveByteGet( &Data)) {
            Data = 0xFF;
         }
         Send( Data);
      } else {
         SetReceiveMode();
         Read();
      }
   } else {
      ClearFlag();
      if(ReadWrite()) {
         if(Acknowledged()) { // ACK, Tx byte
            if(!IicSlaveByteGet( &Data)) {
               Data = 0xFF;
            }
            Send( Data);
         } else { // NACK, turn off Tx
            SetReceiveMode();
            Read();
         }
      } else {
         Acknowledge();
         Data = Read();
         IicSlaveByteProcess(Data);
      }
   }

   CpuIrqEnable( I2C0_IRQn);
} // IicSlaveExecute

void __irq I2C0_IRQHandler( void)

// ISR

{

   CpuIrqDisable( I2C0_IRQn);

} // I2C0_IRQHandler

0 项奖励

814 次查看
perlam_i_au
Senior Contributor I

I also want to know your part number and for code and could you please add your project as a zip file on the comment?

To add documents you only need to open Advanced editor and click over attachment button, then you can add your project :smileygrin:

0 项奖励

814 次查看
martindusek
Contributor V

I don't use Codewarrior. I think it will happen also with your standard IIC driver if you enable STOPIE bit. My part number is MKL02Z32VFM4 (on FRDM-KL02Z).

0 项奖励

814 次查看
perlam_i_au
Senior Contributor I

Well this is not a common error and as long as I cannot reproduce the error my best recommendation for you will be to review the example code included in another thread on the community, please go to: Re: Re: Interrupt in I2C

I hope you find these example codes useful and please let me know what happens.


Have a nice day,
Perla Moncada

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励