This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[Help] RTC BQ32000

Other Parts Discussed in Thread: BQ32000

Hello everybody !!

I tried to calibrtion 1Hz on RTC BQ32000 of TI. 

The calibration process is described below. This calibration process does not works and I would like to know the way in which it should be done correctly. 

 

The steps taken during the calibration procedure were the following:

 

1. Write 0xE0 in the CAL_CFG1 Register during the initialization of the microcontroller . This was done in order to enable the test signal on the IRQ pin of the bq32000.

bit 7 = OUT = 1

bit 6 = FT = 1

bit 5 = S = 1

bit 4, bit 3, bit 2, bit 1, bit 0 = CAL = 00000

 

2. Write 0xFF in the CAL_CFG1 Register. This was done in order to speed the RTC. 

bit 7 = OUT = 1

bit 6 = FT = 1

bit 5 = S = 1

bit 4, bit 3, bit 2, bit 1, bit 0 = CAL = 11111 

This is : CAL(DEC) 31 = -126 ppm.

 

3. Write the key 0x5E in the SF KEY 1 register.

4. Write the key 0xC7 in the SF KEY 2 register.

5. Set the bit FTF (D0) in the SFR Register.  Setting FTF forces the calibration signal to 1Hz, and the calibration tracks the internal ppm adjustment.

6. Read the calibration register CAL_CFG1 Register in order to verify that the bits  4, 3, 2, 1 and 0 = 11111 .

7. Finally, the initial value 10000000b is written to the CAL_CFG1 Register. 

 

The control system continues to be delayed one minute per week, if someone has an idea of something else that could be done please let me know. 

Thanks all. 

  • Hi,

    I am not to familiar with this device but will try to assist.

    Are you saying that you have sped the RTC as much as allowed and it still lags?

  • Thanks for your answer !!

    I have sped the RTC as much as allowed but it still lags !!
     The control system still delayed bout  one minute per week, if someone has an idea of something else that could be done please let me know. 

  • Have you tried with another oscillator? My first thought is that you have an oscillator that is out of tolerance.

    Do you have a screen capture of the waveform after calibration?

  • Sorry sir ! I'm so sad to say that !  I don't have a oscilloscope there fore i can't see the waveform BQ32000

  • How are you performing the calibration? Are you randomly picking a value then comparing against some know constant clock after a set period of time?

    I would definitely try your setup with another model of crystal and see if you get similar results.

  • Sir, I  compared with my PC's clock after a set period of time.

    Below is my main file

    /*
    ************************************************
    Time: 23:45:00
    Date: 07/09/2013
    Code by: Le Thanh Trieu
    Tel: 01688997774
    Email:lethanhtrieuk36@gmail.com
    ************************************************
    Descript:
    Application RTC(Real Time Clock) on LCD.
    Hardware connection:
    //                MSP430G2553
    //             -----------------
    //         /|\|              XIN|-
    //          | |                 |
    //          --|RST          XOUT|-
    //        >---|P2.0        P1.6 |--> SCL
    //  LCD <->   |                 |        <-> RTC BQ32000 Module
    //        >---|P2.5        P1.7 |--> SDA
    //          
    */
    #include "i2c.c"
    #include "conf_lcd.c"
    #include "msp430g2553.h"
    //***********************************
    void conf_io();
    void Init_UART();
    void conf_clock();
    void read_bq32000();
    void display_time();
    void display_date();
    //***********************************
    unsigned char sec_10,sec_1,min_10,min_1,hour_10,hour_1,day,date_10,date_1,month_10,month_1,year_10,year_1;
    unsigned char dataread[8];
    unsigned char datawrite[7] = {0x00,0x43,0x23,0x07,0x07,0x09,0x13};// Time value set to BQ3200
    //*****Calibration 1Hz*****
    unsigned char calbin[1] = {0x40};// write to CAL_CFG1 Register 
    unsigned char out1hz[3]={0x5e,0xc7,0x01};//write to :SF KEY 1 Register,SF KEY 2 Register,SFR Register
    //*************************
    void main( void )
    {
      // Stop watchdog timer to prevent time out reset
      WDTCTL = WDTPW + WDTHOLD;
      conf_io();
      conf_lcd(0);
      conf_clock();
     // Init_UART();
      i2c_init(0x68);
      
      i2c_write(0x07,1,calbin);   //Calibration 1Hz for Pin IR
      i2c_write(0x20,3,out1hz);  
      
      //i2c_write(0x00,8,datawrite);   //Set Time for BQ32000
      
      while(1)
      {
         read_bq32000();//Read time from BQ32000
         display_time(); //Show Time on line 1 LCD
         display_date();//show Date on line 2 LCD 
      }
    }
    void conf_io()
    {
      P2DIR |= 0xff;
      P1DIR |= 0xff;
      P1SEL |= BIT6 + BIT7;                      // Assign I2C pins to USCI_B0 
      P1SEL2|= BIT6 + BIT7;
    }
       
    void Init_UART()
    {	
    #if 1
        P1SEL |= BIT1 + BIT2;                    
      	P1SEL2 |= BIT1 + BIT2;                     
      	UCA0CTL1 |= UCSSEL_2;
            //Baud rate = 1Mhz/9600=104;
     	UCA0BR0 = 104;                           
     	UCA0BR1 = 0;                              
     	UCA0MCTL = UCBRS0;                        
     	UCA0CTL1 &= ~UCSWRST;                     
    	//IE2 |= UCA0RXIE;                          
      	__bis_SR_register(GIE);
    #endif
    }
    void conf_clock()
    {
       if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)                                     
      {  
        while(1);                               // If calibration constants erased
                                                // do not load, trap CPU!!
      }
      BCSCTL1 = CALBC1_1MHZ; //Clock 1MHz
      DCOCTL = CALDCO_1MHZ;   
    }
    void read_bq32000()
    {
      i2c_read(0x00,8,dataread); //Read 8byte,Start from 0x00(Second)
        sec_10 = ((dataread[0] >>4)&0x07);//TEN_SEC 
        sec_1 = (dataread[0] &0x0f); //SEC
        min_10 = ((dataread[1] >> 4) & 0x07); //TEN_MIN
        min_1 = (dataread[1] & 0x0f); //MIN
        hour_10 = ((dataread[2] >> 4) & 0x03);//TEN_HOUR 
        hour_1 = (dataread[2]  & 0x0f);//HOUR
        day = (dataread[3] & 0x07) ;//DAY OF WEEK 
        date_10 = ((dataread[4] >> 4) & 0x03); //TEN_DATE
        date_1 =(dataread[4]& 0x0f); //DATE
        month_10 = ((dataread[5] >> 4) & 0x01); //TEN_MONTH
        month_1 =(dataread[5]& 0x0f); //MONTH
        year_10 = ((dataread[6]>>4) & 0x0F);//TEN_YEAR
        year_1  = (dataread[6]& 0x0f);//YEAR
    }
    void display_time()
    {
        lcd_gotoxy(0,0);
        lcd_puts("Time: ");
       //SHOW: Time
        lcd_gotoxy(6,0);
        lcd_number(hour_10,0,0);
        lcd_gotoxy(7,0);
        lcd_number(hour_1,0,0);
        //Show: ":"
        lcd_gotoxy(8,0);
        lcd_putc(':');
       //Show: Minutes 
        lcd_gotoxy(9,0);
        lcd_number(min_10,0,0);
        lcd_gotoxy(10,0);
        lcd_number(min_1,0,0);
        //SHOW: ":"
        lcd_gotoxy(11,0);
        lcd_putc(':');
        //SHOW: SEC
        lcd_gotoxy(12,0);
        lcd_number(sec_10,0,0);
        lcd_gotoxy(13,0);
        lcd_number(sec_1,0,0);
    }
    void display_date()
    {
        lcd_gotoxy(0,1);
        lcd_puts("Date: ");
       //SHOW: DATE
        lcd_gotoxy(6,1);
        lcd_number(date_10,0,0);
        lcd_gotoxy(7,1);
        lcd_number(date_1,0,0);
        //SHOW: "-"
        lcd_gotoxy(8,1);
        lcd_putc('-');
       //SHOW: MONTH 
        lcd_gotoxy(9,1);
        lcd_number(month_10,0,0);
        lcd_gotoxy(10,1);
        lcd_number(month_1,0,0);
        //SHOW: "-"
        lcd_gotoxy(11,1);
        lcd_putc('-');
        //SHOW: YEAR
        lcd_gotoxy(12,1);
        lcd_number(20,0,0);
        lcd_gotoxy(14,1);
        lcd_number(year_10,0,0);
        lcd_gotoxy(15,1);
        lcd_number(year_1,0,0);
    }

    And I2C Lib: https://dl.dropboxusercontent.com/u/23155150/I2C%20Lib.rar

    Thank you very much sir !!