Discussion in "Project Addition or Changes" started by    pinky    Apr 29, 2007.
Sun Apr 29 2007, 07:53 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, 05:18 pm ]
Tags real time clockasm program16x2 lcdmicrocontrollerrtc
Mon Apr 30 2007, 12:59 am
#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, 04:54 pm
#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, 06:02 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, 06:04 pm ]
Tags rtcp1sdacoz
Fri May 04 2007, 11:57 pm
#5
great help! keep it up Rickey!
Sun May 06 2007, 12:26 pm
#6
Well i need help and contribution from other forum members too.. not just me.. ok?
Wed May 09 2007, 12:20 am
#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 ??????????
Wed May 09 2007, 12:39 am
#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, 10:49 pm
#9
Thankz u .Now i understand
Thu May 10 2007, 12:32 am
#10
you're welcome

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

RosendoChecy
Wed Oct 09 2024, 12:20 pm
Xazriqr
Wed Oct 09 2024, 02:52 am
Danieldok
Tue Oct 08 2024, 07:08 pm
Iariorrew
Tue Oct 08 2024, 01:48 pm
mg2Engax
Tue Oct 08 2024, 04:02 am
Maidan1cet
Mon Oct 07 2024, 11:56 pm
FrancisCow
Mon Oct 07 2024, 08:12 pm
xrGax
Mon Oct 07 2024, 07:53 pm