cancel
Showing results for 
Search instead for 
Did you mean: 

Stm8 I2c Data Reception problem

nitin110051
Associate II
Posted on June 18, 2014 at 07:38

hi clive

I am using Stm8 for using as i2c slave Device

& stm32 as master .

From master I am Sending 2 bytes of  Data after  address

 Problem i am getting is I am getting Data Only once after that only ist byte of data .

Here is  some Lines of Codes From Handler.

INTERRUPT_HANDLER(I2C_IRQHandler, 19)

{

    uint8_t b;

  if((I2C->SR1 & 0x02 )== 0x02)

 {

  b+=I2C->SR1;

  b+=I2C->SR3;

 }

 

 if ((I2C->SR1 & 0x40) ==0x40 )

 {

  test1= I2C->DR;

 }

 //recieve[a]= I2C->DR;

 if ((I2C->SR1 & (0x40|0x04)) ==(0x40|0x04) )

 {

  b=I2C->SR1;

  test2= I2C->DR;

 }

 

  if((I2C->SR1 & 0x10)== 0x10)

 {

  b+=I2C->SR1;

  I2C->CR2|= 0x02;

 }

     

   GPIOB->ODR^=1;

  }
2 REPLIES 2
Stm32User
Associate II
Posted on June 23, 2014 at 14:58

Read errata there are problems with I2C hardware

vance
Associate II
Posted on June 27, 2014 at 16:36

Maybe using the standard peripheral library for the stm8 would help things. It has helpful functions for changing flags and sending and receiving data in a more abstract manner. I2C was quite tough for me to get working even with the library...