Discussion in "Project Addition or Changes" started by    pinky    Apr 29, 2007.
Sun Apr 29 2007, 02:23 PM
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
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..
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
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 TL0,#00H
MOV TH0,#00H

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
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
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*
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
great help! keep it up Rickey!
Sun May 06 2007, 06:56 AM
Well i need help and contribution from other forum members too.. not just me.. ok?
Tue May 08 2007, 06:50 PM
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
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

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

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
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

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


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
Thankz u .Now i understand
Wed May 09 2007, 07:02 PM
you're welcome

Get Social


Powered by e107 Forum System


Sat May 15 2021, 11:47 AM
Derek Wolcott
Geometric Energy Corporation announced the dogecoin-funded mission on Sunday, with DOGE-1 representing a 40 kilogram cube satellite flying as a payload on a Falcon 9 rocket.
Thu May 13 2021, 07:18 PM
Pretty section of content. I just stumbled upon your weblog and in accession capital to assert that I get actually enjoyed account your blog posts. Any way I will be subscribing to your augment and even I achievement you access consistently quickly. https://mkfinstitute.com Trisha Trisha
Wed May 12 2021, 01:23 PM
Jed Roan
Now you can promote your site all over the internet for FREE: http://www3.listofsitesthatacceptfreeads.club
Wed May 12 2021, 08:20 AM
If some one wants to be updated with most recent technologies afterward he must be visit this web page and be up to date every day. annual credit report https://creditscoresetf.com
Wed May 12 2021, 06:11 AM
Great website. A lot of useful information here. I'm sending it to some pals ans also sharing in delicious. And of course, thanks on your effort! annual credit report https://creditscorecheckn.com



Thu Jun 25 2020, 03:46 PM
Mon Jun 22 2020, 03:03 PM
Tue Jun 16 2020, 05:10 PM
Sat Jun 13 2020, 09:43 PM
Thu May 21 2020, 12:44 PM
Thu May 21 2020, 01:28 AM
Wed May 20 2020, 07:05 PM
Wed May 20 2020, 11:52 AM


Guests: 116, Members: 0 ...

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

Members: 38215
Newest member: Mirza123