Discussion in "Project Addition or Changes" started by    pinky    Apr 29, 2007.
Sun Apr 29 2007, 02:23 PM
#1
i am trying to implement a real time clock using an 16x2 LCD microcontroller AT89C5131 in our project.
we want only the clock part without the alarm and i removed some part of the clock.asm program and tried but its not working.our lcd is working properly.we are trying to display date,time and day only
i want to know if the code given below will work
additional change is i have given a small delay before actual starting.

Code removed!



[ Edited Mon Apr 30 2007, 11:48 AM ]
Tags real time clockasm program16x2 lcdmicrocontrollerrtc
Sun Apr 29 2007, 07:29 PM
#2
actually you did not edited the code properly.
you removed many things which were necessary for the clock. I am giving you one example...
In your code above there is a mistake..
done:
mov sec,#00h ;For more information about the RTC DS1307
mov min,#0h ;Please refer to the datasheet
mov hour,#51h ;21h for 24 hour format
mov days,#01h
mov date,#1h
mov month,#1h
mov year,#05h
;;;LINE MISSING;;;
mov sig,#'~'
mov r6,#07h
mov r0,#30h
mov r1,#00h
acall rtc_ini ;initializing RTC if required

there is a line missing.. i mentioned where...
you missed..
mov alarm,#0

the reason is.. if you take a look at the datasheet of DS1307 then register #7 is SQWT register so.. as we are not using it, so we have to make it 0. The reason i made kept its name as alarm was, i was first driving the alarm from internal square wave generator but then i changed it. if you want you can keep the old name. or change the alarm to sqwt for your knowledge.
so make these changes in above code..
put the missing line there and change this
mov r6,#08h

make it 08H u using 07H

and i do not understand why you are putting this code
MOV R7,#0FFH
BACK1:MOV TMOD,#01H
MOV TL0,#00H
MOV TH0,#00H
SETB TR0
HER:JNB TF0,HER
CLR TF0
CLR TR0
DJNZ R7,BACK1

Please explain the use of this. and check what all things are missing in the code. i think you must start reviewing the original code again and rewrite the original one according to your need.
Tags movrtcr7r6wave generator
Mon Apr 30 2007, 11:24 AM
#3
thanks for the advice...
actually had a doubt in understanding the code.
wanted to know why exactly time flag and alarmflag used...and also the increament and decreament flag.
can we do without using switches.i.e is it for setting time in clock or setting time for alarm...
Tags setting timetime flagswitchesdoubtclock
Mon Apr 30 2007, 12:32 PM
#4
I removed the code from the first post, coz no more needed.
So regarding the information about the flags i used.. i am gonna explain then one by one.. all the defination in the code.
sec equ 30h       ;second register *needed*
to store RTC seconds
min equ 31h      ;minutes register *needed*
to store mins
hour equ 32h     ;hour register *needed*
to store hr
days equ 33h     ;days register *needed*
to store days
date equ 34h     ;date register *needed*
to store date
month equ 35h   ;month register *needed*
to store month
year equ 36h      ;year register *needed*
to store year
alarm equ 37h    ;alarm register *needed*
it is written as alarm but it is used for SQWT register of
your RTC. so is also needed, if you want change the name to
sqwt or something u want.
sig equ 38h       ;signature for data checking in RTC RAM *needed*
needed for checking of valid ram content of RTC
ahour equ 39h   ;alarm hour register
for alarm only can be removed
amin equ 3Ah    ;alarm minute register
for alarm only can be removed
sda equ P1.1     ;Serial data pin *needed*
SDA pin for I2C
scl equ P1.0       ;Serial clock pin *needed*
SCL pin for I2C communication
rw equ p3.6        ;read write pin of LCD
for LCD
en equ p3.5       ;enable pin of LCD
for LCD
rs equ p3.7        ;register select pin of LCD
for LCD
alarm_key equ p3.3   ;Alarm set key
to set alarm.. not needed.. so one key can be removed. and
also the subroutine at location 0x13H
time_key equ p3.2    ;Time ser key *needed*
to set time of clock
increment equ p1.3   ;Increment value *needed*
to set time and alarm, but for u it will only time
decrement equ p1.2   ;Decrement Value *needed*
to set time and alarm, used to reduce the value
alarm_port equ p1.4   ;Alarm Buzzer port
not required
alarm_flag equ 20h    ;flag for alarm
not required
time_flag equ 21h      ;flag for time *needed*
when u press time set key this flag is set.
ampm_flag equ 22h    ;am/pm flag *needed*
used in display am/pm
alarm_on equ 23h       ;Alarm on flag
not required
alarm_off equ 24h       ;alarm off flag
not required
alarm_ring equ 25h      ;alarm ring flag
not required
alarm_hrs equ 58h       ;Alarm hour register
not required
alarm_min equ 59h      ;Alarm Minutes register
not needed
alarm_chk_hour equ 5Ah ;Alarm hour check register
not needed
alarm_chk_min equ 5Bh  ;Alarm min check register
not required
ampm equ 61h           ;AM/PM register *needed*
needed 
BELL equ 0h               ;Bell icon *needed*
SPEAKER_OFF equ 1h  ;speaker off icon *needed*
SPEAKER_ON equ 2h    ;speaker on icon *needed*
CLOCK equ 3h           ;clock icon *needed*
OK equ 4h                 ;ok icon *needed*
HEART equ 5h            ;heart icon *needed*
MUSIC equ 6h            ;music icon *needed*

U can see what things are needed, what variables or flags
needed. Please carefully edit the code now.


[ Edited Mon Apr 30 2007, 12:34 PM ]
Tags rtcp1sdacoz
Fri May 04 2007, 06:27 PM
#5
great help! keep it up Rickey!
Sun May 06 2007, 06:56 AM
#6
Well i need help and contribution from other forum members too.. not just me.. ok?
Tue May 08 2007, 06:50 PM
#7
In your code , there's a label i dont understand .it's the
algorthm to read data from ds1307

recv: ;Recieving data from I2C bus
mov r7,#08
back2:
setb sda
setb scl
lcall delay ;nop nop nop;
mov c,sda
rlc a
clr scl
lcall delay ;nop nop nop;
djnz r7,back2
setb sda
clr scl
lcall delay ;nop nop nop;
clr sda
setb scl
lcall delay ;nop nop nop;
clr scl
lcall delay ;nop nop nop
mov @r0,a
inc r0
ret

SDA=1 => C=1 , then A =11111111 after 8 times shift left ??????????
Tue May 08 2007, 07:09 PM
#8


In your code , there's a label i dont understand .it's the
algorthm to read data from ds1307

recv: ;Recieving data from I2C bus
mov r7,#08
back2:
setb sda
setb scl
lcall delay ;nop nop nop;
mov c,sda
rlc a
clr scl
lcall delay ;nop nop nop;
djnz r7,back2
setb sda
clr scl
lcall delay ;nop nop nop;
clr sda
setb scl
lcall delay ;nop nop nop;
clr scl
lcall delay ;nop nop nop
mov @r0,a
inc r0
ret

SDA=1 => C=1 , then A =11111111 after 8 times shift left ??????????

NiceThou


I thought everything was mentioned clearly...
recv: ;Receiving data from I2C bus
it is to receive data from I2C bus...
and yes, if u keep SDA = 1 so while reading C will also be 1.
but everytime the clock changes, the new data comes on the SDA pins. so next can be 0 or 1.
if whole data is 1, then u get a = 11111111
Wed May 09 2007, 05:19 PM
#9
Thankz u .Now i understand
Wed May 09 2007, 07:02 PM
#10
you're welcome

Get Social

Information

Powered by e107 Forum System

Conversation

Wed Jan 22 2020, 06:16 PM
MINU CHAUDHARY
I m getting errors while simulation process during interfacing socket output and lcd... Can i get the report of ur project which is same as us.
Tue Jan 14 2020, 07:08 AM
shubham kharade
when i am trying to simulate the program in Proteus 8 professional, I am getting some errors as cannot find module file dhtxx.md can u help me
Tue Dec 17 2019, 01:44 PM
Devangi
hello..i am programming industrial timer using 8051 with 24lc64 eeprom. i have query in storing the 3 diff value in eeprom with enter button. can anyone share c code ?
Tue Dec 17 2019, 10:30 AM
Andrius
Hello. Can anyone share the code in Bascon and scheme in Proteus?
Thu Nov 21 2019, 12:30 PM
raj2555
how to interface 8051 microcontroller with NRF24L01+ module
ExperimenterUK
Sat Oct 12 2019, 10:23 PM
Log in.. then post your code in the 8051 forum
Sat Oct 12 2019, 10:18 AM
Bhadra Sajikumar
i am doing a countdown timer with 8051 for my project, unfortunately our professor had to take a leave of absence before he could teach us most of it.. can someone explain the .asm code of it for me?
Mon Sep 23 2019, 07:37 AM
Nathaniel
I am doing a project for my schools wireless security system with cameras,sensors and spot lights using 8051 micro controller, could you help me out with the design and its source code.
Wed Sep 18 2019, 08:48 PM
Caryn Kover
Thank you for your time,
ExperimenterUK
Mon Aug 05 2019, 07:09 PM
@Ismail ..post in forum, give details

Downloads

Comments

brucewilliams20
Thu Jan 23 2020, 11:47 AM
Nippy56
Sun Jan 19 2020, 02:13 AM
usb5962
Sat Jan 11 2020, 10:42 AM
elt
Tue Jan 07 2020, 06:53 PM
mg3914697
Tue Jan 07 2020, 12:42 PM
afds43
Sun Dec 29 2019, 05:54 AM
Rupeshpatil
Fri Dec 27 2019, 06:14 PM
pyxus
Sat Dec 14 2019, 12:31 PM

Online

Guests: 57, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38117
Newest member: brucewilliams20
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Jan 17 2020, 10:24 PM
We will need the circuit diagram.A Proteus simulat...
Billz Avatar
Posted By Billz
Sat Jan 11 2020, 05:43 PM
hi everyone please attached files are my c code fo...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Jan 07 2020, 08:18 PM
Not a stupid question.Setting up "Eclipse" can be...
elt Avatar
Posted By elt
Tue Jan 07 2020, 07:06 PM
So i have just began learning programming micros a...
Billz Avatar
Posted By Billz
Mon Jan 06 2020, 09:22 PM
I think it would be better if you guys try to come...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Jan 06 2020, 12:22 AM
Can you post a circuit diagram and any code you ha...
Billz Avatar
Posted By Billz
Sun Jan 05 2020, 08:17 PM
Need help regarding C code (specifically for PIC 1...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Dec 30 2019, 06:42 PM
Can you give more details of your problem.
Rupeshpatil Avatar
Posted By Rupeshpatil
Fri Dec 27 2019, 06:21 PM
How to copy program my old microcontroller to new ...
ilylily07 Avatar
Posted By ilylily07
Thu Dec 12 2019, 02:26 PM
wil do.thank you for your advice!