Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Proteus 7.7SP2 problem with DS1338

Status
Not open for further replies.

sadat007

Full Member level 4
Joined
Dec 31, 1999
Messages
235
Helped
13
Reputation
26
Reaction score
7
Trophy points
1,298
Location
Pakistan
Activity points
1,773
Hi,
I tried to simulate DS1338 with following simple codes. The same code worked fine with DS1307 but with DS1338 the internal registers will not update or change. That is the seconds print keep printing fixed value of the seconds which loaded at startup from system clock. Note that the main time and date registers are same for the both.
Thanks
Sadat007

$baud = 9600
$crystal = 22118400
$regfile = "8052.DAT"
$large

Const Ds1307w = &HD0
' Write
Const Ds1307r = &HD1
' Read
Const Sec_addmap = &H00
Const Min_addmap = &H01
Const Hour_addmap = &H02
Const Control_addmap = &H07
Dim Reg_sec As Byte
Dim Reg_min As Byte
Dim Reg_hour As Byte
Dim Tempb As Byte
Config Sda = P1.6
Config Scl = P1.5

Clock_init:
' double key stroke
Reg_sec = 33
Tempb = Reg_sec And &B01111111
' start Oscillator Enable bit 7 of seconds put 0
I2cstart
I2cwbyte Ds1307w
I2cwbyte Sec_addmap
I2cwbyte Tempb
I2cstop
' Generate Stop


Loop1:
I2cstart
' Generate start
I2cwbyte Ds1307w
' Slave adsress
I2cwbyte Sec_addmap
' Address of SECONDS REG
I2cstop
' Generate Stop
I2cstart
' Repeated start
I2cwbyte Ds1307r
' Slave address (read)
I2crbyte Reg_sec , Ack
I2crbyte Reg_min , Ack
I2crbyte Reg_hour , Nack
I2cstop
'Reg_hour = Reg_hour And &B00011111
' remove 12/24 set and am/pm bits
' set numeric variables
'Num_hour = Makedec(reg_hour)
'Num_min = Makedec(reg_min)
'Num_sec = Makedec(reg_sec)
Print Reg_sec
Wait 1
Goto Loop1
 

how do you know that the i2crbyte is reading anything back from the rtc?

one way to check would be to assign Reg_sec a differrent value (from 33) right after "Tempb = Reg_sec And &B01111111 " in the Clock_init routine.
 

Its reading because, for DS1338, if i do not write on sec reg then the read command gives same seconds value as my PC clock. Also the same codes working fine on DS1307.
Thanks
sadat007
 

if i do not write on sec reg then the read command gives same seconds value as my PC clock.

that's a practical impossibility.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top