problem with DS3231 and pic16F876A

Discussion in 'Embedded Systems and Microcontrollers' started by kimou, Mar 29, 2011.

  1. kimou

    Thread Starter New Member

    Mar 29, 2011
    1
    0
    Hello,
    I'm new to this forum, I try to display the time and date from the component RTC :DS3231S, the result is displayed on an LCD display, I used this program:
    // LCD
    sbit LCD_RS at RB4_bit;
    sbit LCD_EN at RB5_bit;
    sbit LCD_D4 at RB0_bit;
    sbit LCD_D5 at RB1_bit;
    sbit LCD_D6 at RB2_bit;
    sbit LCD_D7 at RB3_bit;
    // Configuration PIN LCD
    sbit LCD_RS_Direction at TRISB4_bit;
    sbit LCD_EN_Direction at TRISB5_bit;
    sbit LCD_D4_Direction at TRISB0_bit;
    sbit LCD_D5_Direction at TRISB1_bit;
    sbit LCD_D6_Direction at TRISB2_bit;
    sbit LCD_D7_Direction at TRISB3_bit;
    void main()
    {
    // Declaration

    unsigned int secondes,sec1,op1,Tr1;
    unsigned int minutes;
    unsigned int hours;
    unsigned int day;
    unsigned int mounth;
    unsigned int year;
    unsigned int temp;
    char*DATE;
    char buffer1[8], buffer2[8], buffer3[8];
    // Initialisation LCD
    LCD_Init();
    LCD_Cmd(_LCD_CLEAR);
    LCD_Cmd(_LCD_CURSOR_OFF);
    while(1)
    {
    // Communication I²C
    I2C1_Init(10000); // initialisation I²C

    I2C1_Start(); // Start I²C
    I2C1_rd(0xD0); // Adress Ds3231
    sec1=I2C1_rd(0x00); // read secondes
    Tr1=BCD2DEC(sec1);
    IntToStr(Tr1,buffer1);
    Lcd_Out(1,1,buffer1);
    I2C1_Stop(); // Stop signal I²C
    Delay_100ms();
    }
    }
    the problem is when i execute my program in simulation (Proteus), the circuit work, but on a reality, the LCD is stuck on the value 149
    Note:
    in the program, several variables are declared but not used, my priority is to read and display the seconds
    I don't know where is a mistake in my program,....please, who can help me ... Thanks
     
Loading...