cancel
Showing results for 
Search instead for 
Did you mean: 

RTC BQ32000 interfacing with stm32f030

kapilkumar
Associate
Posted on September 08, 2016 at 12:47

Hi

I am trying to write some data to RTC register(say, day register) but unable to do so. If anyone knows,please provide some useful suggestions regarding what is the problem with the below code.

// writing code part.

void RTC_Write(uint8_t addr, uint8_t data)

{

 

    while(I2C_GetFlagStatus(I2C2, I2C_ISR_BUSY)==RESET);

    I2C_GenerateSTART(I2C2, ENABLE);

    I2C_SendData(I2C2,SLAVE_ADDR);

    I2C_SendData(I2C2,(uint8_t)addr);

    while(I2C_GetFlagStatus(I2C2, I2C_ISR_TC) == RESET);

    I2C_SendData(I2C2,(uint8_t)data);

    while(I2C_GetFlagStatus(I2C2, I2C_ISR_TC) == RESET);

    I2C_GenerateSTOP(I2C2, ENABLE);

    while(I2C_GetFlagStatus(I2C2, I2C_FLAG_STOPF)==RESET);

   

}

void main()

{

time.day=RTC_Write(DAY_ADD,(uint8_t)0x01);     //0x01= sunday.

printf(''Day: %x\r\n'',time.day);

}

Regards,

Kapil.
2 REPLIES 2
slimen
Senior
Posted on September 08, 2016 at 13:28

Hi,

You can review RTC examples under the

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-embedded-software/stm32cubef0.html

firmware package:  STM32Cube_FW_F0_V1.6.0\Projects\STM32091C_EVAL\Examples\RTC

This will help you to develop and configure your project.

Regards

kapilkumar
Associate
Posted on September 09, 2016 at 06:40

whatever you had given me the link , that is for internal rtc. i am looking to interface external rtc to stm32f030 using i2c. if anyone have some sample code related to it , please share with me.

Regards,

Kapil.