-
Ordering information
Call us or mail us for inquiries & availability: info@mtronixtech.com
-
Search projects by Price
-
Project Categories
- Robots and Robotics
- GSM based Projects
- GPS based Projects
- RFID based Projects
- Energy Saving
- Wireless Communication
- DTMF based projects
- SMS based projects
- RF Remote
- Mobile Controlled
- Power Saver
- Sensor based Projects
- Alcohol Sensor
- heartbeat Sensor
- Humidity Sensor
- Infrared Sensor
- Level Sensor
- Light Sensor
- LPG Gas Sensor
- Moisture Sensor
- Temperature Sensor
- Vibration Sensor
- Weight Sensor
-
Search projects by Application
Project Videos:
Landrover Robot Operated by Cellphone
Industrial Automation using Cellphone
Password based door locking
Automatic room light controller
Temperature controlled fan
Electronic voting machine
Search by Components
89c51 89s51 89s52 89v51RD2 555 ADC0808 ADC0809 AT24c16 AT24c64 AT89s52 Battery BC547 Bulb Buzzer Darlington Pair DC motor Decoder EEPROM Fan GPS GSM IR LED Keypad L239D LCD Display LDR LED LM35 LM358 Matrix keypad MAX232 Motor Driver MQ6 PC Interface Relay RFID Card RFID Reader RFID Tags Sim300 sim900 SR86 SR87 Stepper Motor SYHS220 TSOP1738
Real Time Clock interfacing with 8051
Sample code for Real Time Clock interfacing with 8051.
Following code can be using for 8051 and 8052 ICs like: 89c51, 89c52, 89s51, 89s52, 89c2051.
;========================================================= ; Downloaded from www.projectsof8051.com ; MicroTronics Technologies ;========================================================= ;====RTCTIME.ASM: SETTING TIME,READING AND DISPLAYING IT========= ORG 0000H ACALL DELAY_200ms ;RTC NEEDS 200ms UPON POWER UP SETB P3.6 CLR P3.6 ;====TURNING ON THE RTC========================================= MOV DPTR,#10 ;R0=0AH,REG. A ADDRESS MOV A,#20H ;010 IN D6-D4 TO TURN ON OSC. MOVX @DPTR,A ;SEND IT TO REGISTER A OF RTC ;====SETTING THE TIME MODE====================================== SETB P3.6 CLR P3.6 MOV DPTR,#11 ;REG. B ADDRESS MOV A,#83H ;BCD,24 HRS ,DAYLIGHT SAVING MOVX @DPTR,A ;SEND IT TO REG R ;====SETTING THE TIME========================================= SETB P3.6 CLR P3.6 OUT1: ACALL DELAY MOV DPTR,#00 ;POINT TO SECONDS ADDRESS MOV A,#01H ;SECONDS=00H MOVX @DPTR,A ;SET SECONDS SETB P3.6 CLR P3.6 ACALL DELAY MOV DPTR,#02 ;POINT TO MINUTES ADDRESS MOV A,#03H ;MINUTES=O00H MOVX @DPTR,A ;SET MINUTES SETB P3.6 CLR P3.6 ACALL DELAY MOV DPTR,#04 ;POINT TO HOURS ADDRESS MOV A,#02H ;HOURS=00H MOVX @DPTR,A ;SET HOURS SETB P3.6 CLR P3.6 ACALL DELAY MOV DPTR,#11 ;REG B ADDRESS MOV A,#03 ;D7=0 OF REG B TO ALLOW UPDATE MOVX @DPTR,A ; SEND IT TO REGISTER B SETB P3.6 ;DISABLING THE WRITE SIGNAL ;====INITIALSING LCD============================================ MOV A,#80H ACALL command MOV A,#38H ACALL command MOV A,#0EH ACALL command MOV A,#01H ACALL command ACALL delay MOV A,#80H ACALL command MOV DPTR,#LINE_1 NXT1: MOV A,#00H MOVC A,@A+DPTR JZ OUTx ACALL DISPLAY ;/--("TIME:") INC DPTR SJMP NXT1 ;====READING TIME============================================== outx: AGAIN1: MOV DPTR,#04 SETB P3.7 CLR P3.7 ;SET READ ACALL DELAY MOVX A,@DPTR ;READ SECONDS MOV P0,A ACALL DISPLAYNUM MOV A,#':' ACALL DISPLAY MOV DPTR,#02 ;POINT TO SEC. LOC. SETB P3.7 CLR P3.7 ;SET READ ACALL DELAY MOVX A,@DPTR ;READ SECONDS MOV P0,A ACALL DISPLAYNUM MOV A,#':' ACALL DISPLAY MOV DPTR,#00 ;POINT TO SEC. LOC. SETB P3.7 CLR P3.7 ;SET READ ACALL DELAY MOVX A,@DPTR ;READ SECONDS MOV P0,A ACALL DISPLAYNUM ACALL DELAY_1SEC MOV A,#86H ;GOING BACK TO 1ST LINE & 6TH POSITION ACALL command SJMP AGAIN1 ;====LCD COMMAND & DATA SUBROUTINE============================= command: acall ready mov p1,a clr p3.3 clr p3.4 setb p3.5 clr p3.5 ret ready: setb p1.7 clr p3.3 setb p3.4 check1: clr p3.5 setb p3.5 jb p1.7,check1 ret display: acall ready mov p1,a setb p3.3 clr p3.4 setb p3.5 clr p3.5 ret DISPLAYNUM: MOV B,A SWAP A ANL A,#0FH ORL A,#30H ACALL DISPLAY MOV A,B ANL A,#0FH ORL A,#30H ACALL DISPLAY RET ;====DELAY SUBROUTINE====================================== ;====200MSEC SUBROUTINE====================================== DELAY_200ms: MOV R1,#4 HERE1: MOV R2,#250 HERE: NOP NOP DJNZ R2,HERE DJNZ R1,HERE1 RET ;====SIMPLE DELAY========================================== delay: MOV R1,#10 HERE11: MOV R2,#0FAH HEREX: NOP NOP DJNZ R2,HEREX DJNZ R1,HERE11 RET ;====ONE SECOND DELAY=================================== DELAY_1SEC: MOV TMOD,#01 ;Timer 0, 16-bitmode mov r1,#0Ah xx2: mov r0,#64h xx1: MOV TL0,#0FDh ;TL0=0, the low byte MOV TH0,#92h ;TH0=0, the high byte SETB TR0 ;Start timer 0 AGAIN: JNB TF0,AGAIN djnz r0,xx1 djnz r1,xx2 ;Monitor timer flag 0 CLR TR0 ;Stop the timer 0 CLR TF0 ;Clear timer 0 flag here1: sjmp here1 ;==== org 350h LINE_1: DB 'TIME: ',0 END ;========================================================= ; Downloaded from www.projectsof8051.com ; MicroTronics Technologies ;=========================================================