AnsweredAssumed Answered

RTC BQ32000 interfacing with stm32f030

Question asked by kumar.kapil.001 on Sep 8, 2016
Latest reply on Sep 9, 2016 by kumar.kapil.001
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.

Outcomes