Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

RTC DS1337 Datasheet

Status
Not open for further replies.

jab99407

Member
I have read DS1337 Datasheet then I have made some steps to send some data to DS1337 in following picture.

I want to write pseudo code for these steps. any help would be appreciated
1576913674528.png
 

Attachments

  • DS1337-DS1337C.pdf
    289.6 KB · Views: 192
Why pseudo code? Send bits or bytes level?
Mike.
just for basic idea

I am sending five bytes. I needs loop that will send each byte and check weather slave is sending A/N. I want to create a pseudo code that satisfies all the conditions in image

Code:
void main ()
{
  start();

  for ( i = 0; i <5; i++ )
  {

  }

}
 
It really depends on the hardware you're using.

I.E. on a pic chip this is the code I use to send a byte,
Code:
char I2cSendByte(unsigned char data){
    SSPBUF=data;
    WaitSSP();
    return(!SSPCON2bits.ACKSTAT);
}
Note that the bit (SSPCON2bits.ACKSTAT) is the set/cleared dependent on if an ACK was received.

Mike.
Edit, some bitbanged code may help you.
 
Mike.
Edit, some bitbanged code may help you.
I got idea from your example

Function pass byte and check A/N. if its return A then send the next byte as image show. But i don't understand how to do that

Code:
char I2cSendByte(unsigned char data){
  
      for ( i = 0; i <5; i++ )
      {

      }
  
     if (conition() = A);
           return A;
     else
          return N
}
 
It's 8 bits of data. In pseudo code you can call it whatever you want.

Mike.
 
The DS1337 doesn't care how you store it on the master end. It just wants a 7 bit address followed by a R/W bit. Note, technically the address is 0x68 not 0xD0 as you show above.

Personally, I'd store it as an unsigned char or uint8_t or byte etc.

Mike.
 
The DS1337 doesn't care how you store it on the master end. It just wants a 7 bit address followed by a R/W bit. Note, technically the address is 0x68 not 0xD0 as you show above.

Personally, I'd store it as an unsigned char or uint8_t or byte etc.

Mike.
Given in datasheets
Seconds Address-(0x00H)- range (00-59)
Minutess Address-(0x01H)- range (00-59)

I think Seconds register and minutes register should be set to 0x00

Code:
unsigned char SecondsRegister = 0x00H
unsigned char MinutesRegister = 0x00H
 
Do you understand how I2C works as your questions make no sense.

Mike.
Yes i understand. first post show my understanding to write operation. In this I have shown how to send byte from master to DS1337. I have to store this data in the master first. Only then I can send this data to Slave. I stored the address of Slave and address of seconds register.
assuming I have sent slave address then second register address and now I want to send data that may be range 00 to 59

What is meaning of range between 00 to 59 ? I think I have to set register to 00 and value of register will increment by one up to 59 counts
 
Last edited:
It's a real time clock! Register zero contains the seconds and can only contain values between 0 and 59.

Mike.
 
It's a real time clock! Register zero contains the seconds and can only contain values between 0 and 59.

Mike.
Master would send value from 0 to 59 in Register zero.

Do we need loop to do this

Code:
for (N=0; N<59; N++)
{
  SecondRegister = SecondValue;
}
 
Sorry jab99407, are you member Gajyamadake in the AAC forum? Pretty much your same style.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top