cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding I2C communication using Polling method. In "Status register 3 (I2C_SR3)" Bit 1 always set BUSY:

AKota.9
Associate

We are interfacing "DS1307" RTC chip with STM8L152C6 Discovery board using I2C polling method.

with clock setting as mentioned bellowed .

void clock_setup(void)

{   

  static uint32_t Clock_frequency = 0;

  CLK_DeInit();/*Deinitializes the CLK peripheral registers to their default reset values.*/

CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_HSI);/*Configures the System clock (SYSCLK) source System Clock Source HSI.*/

CLK_HSICmd(ENABLE);/*Enables Internal High Speed oscillator (HSI)*/

CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_2);/*Configures the System clock (SYSCLK) dividers.System Clock Divider: 16 */

CLK_PeripheralClockConfig(CLK_Peripheral_I2C1,ENABLE);/*Peripheral Clock Enable 2, ADC1*/ 

  Clock_frequency = CLK_GetClockFreq();/*Returns the frequency of the System clock (SYSCLK)*/

}

void GPIO_setup(void)

{

  GPIO_DeInit(GPIOC);

GPIO_Init(GPIOC, GPIO_Pin_0,GPIO_Mode_Out_OD_HiZ_Fast); /*SDA pin as PC0*/

GPIO_Init(GPIOC, GPIO_Pin_1,GPIO_Mode_Out_OD_HiZ_Fast); /*SCL pin as PC1*/

After this setting

void I2C_setup(void)

{

  I2C_DeInit(I2C1);

I2C_Init(I2C1,I2C_MAX_STANDARD_FREQ,0xD0,I2C_Mode_I2C,I2C_DutyCycle_2,I2C_Ack_Enable,I2C_AcknowledgedAddress_7bit);

I2C_Cmd(I2C1,ENABLE);

 flag2 = I2Cx->SR3; /*This flag always remain at 0x02 hence I2C communication is not getting started */

Always BUSY flag in set (1) Hence I2C communication is not completed. function name.

ErrorStatus I2C_CheckEvent(I2C_TypeDef* I2Cx, I2C_Event_TypeDef I2C_Event)

 flag2 = I2Cx->SR3; /*This flag always remain at 0x02 hence I2C communication is not getting started */

0 REPLIES 0