7@rB
Junior Member level 3
- Joined
- Feb 19, 2012
- Messages
- 25
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 1,283
- Location
- Lebanon
- Activity points
- 1,458
hello,
am using a pic18f4525 microcontroller with an interface with a pcf8583 (RTC) and a 16x2 LCD, everything is going right and the time is appearing at the LCD, that is with simulation on proteus.
my question is:
the time appearing with the simulation is correct (the real time), but it is taken from the computer!, when I move for the real application (testing with bread board) what time will be displayed and what is the method or the way to initialize or set the time of the RTC?!
this is a part of my code:
I tried to set the time using buttons by which I increase the hours variable for example when pushing one of these buttons but the time then reaches 27:24:12 for example!
help plzzz
am using a pic18f4525 microcontroller with an interface with a pcf8583 (RTC) and a 16x2 LCD, everything is going right and the time is appearing at the LCD, that is with simulation on proteus.
my question is:
the time appearing with the simulation is correct (the real time), but it is taken from the computer!, when I move for the real application (testing with bread board) what time will be displayed and what is the method or the way to initialize or set the time of the RTC?!
this is a part of my code:
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 void Read_Time() { Soft_I2C_Start(); // Issue start signal Soft_I2C_Write(0xA0); // Address PCF8583, see PCF8583 datasheet Soft_I2C_Write(2); // Start from address 2 Soft_I2C_Start(); // Issue repeated start signal Soft_I2C_Write(0xA1); // Address PCF8583 for reading R/W=1 seconds = Soft_I2C_Read(1); // Read seconds byte minutes = Soft_I2C_Read(1); // Read minutes byte hours = Soft_I2C_Read(1); // Read hours byte day = Soft_I2C_Read(1); // Read year/day byte month = Soft_I2C_Read(0); // Read weekday/month byte Soft_I2C_Stop(); // Issue stop signal } //-------------------- Formats date and time void Transform_Time() { seconds = ((seconds & 0xF0) >> 4)*10 + (seconds & 0x0F) ; // Transform seconds minutes = ((minutes & 0xF0) >> 4)*10 + (minutes & 0x0F); // Transform months hours = ((hours & 0xF0) >> 4)*10 + (hours & 0x0F); // Transform hours year = (day & 0xC0) >> 6; // Transform year day = ((day & 0x30) >> 4)*10 + (day & 0x0F); // Transform day month = ((month & 0x10) >> 4)*10 + (month & 0x0F); // Transform month }
I tried to set the time using buttons by which I increase the hours variable for example when pushing one of these buttons but the time then reaches 27:24:12 for example!
help plzzz
Last edited by a moderator: