DS1307 in assembly for 9S08

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DS1307 in assembly for 9S08

Jump to solution
4,401 Views
RogerSchaefer
Contributor III

Hello,

I have used the I2C for serial EEPROMS but seem unable to get my code to work for the DS1307 RTC.  I must have some sort of blind spot.

 

Does anyone have assembly code for the DS1307 they can share?

 

Roger

Labels (1)
0 Kudos
Reply
1 Solution
2,173 Views
RogerSchaefer
Contributor III

Thanks for the effort, Mac, but I really wanted to get the I2C module working.  I finally did after quite of bit of debuggin.

 

Anyone else want assembly code for the DS1307 clock chip I have it posted on my website:

http://www.rasmicro.com/DS1307.htm

 

Roger

View solution in original post

0 Kudos
Reply
7 Replies
2,173 Views
bigmac
Specialist III

Hello Roger,

 

Two considerations come to mind where the DS1307 may differ from an EEPROM device -

  1. Do you have the correct slave address ($D0 for write, and $D1 for read)?
  2. Does the clock rate exceed 100kHz?

 

Regards,

Mac

 

0 Kudos
Reply
2,173 Views
RogerSchaefer
Contributor III

Hi Mac,

 

Yes, I have the correct slave address and I have set the IIC to 25KHz during debugging.

My assembly code is based on that you posted on the forum some time ago.

No problem with EEPROM.

What is frustrating is that I KNOW how to interface a DS1307.  I did it years ago for a MC68HC11 using bit-banging.

See http://www.rasmicro.com/DS1307.htm

 

There is something about the IIC module that I am not understanding.

 

Roger

0 Kudos
Reply
2,173 Views
bigmac
Specialist III

Hello Roger,

 

I had a closer look at AN1759, pertaining to the DS1307 in conjunction with the ancient HC705 family.  While this is "bit-banging" code, its implementation does not appear to be particularly complex, and speed is not an issue since IIC is a relatively slow process anyway.  I adapted the code for HCS08 devices, making extensive use of macros to make the sequence clearer.  This code is attached, but is untested as I don't have the requred hardware setup.

 

If this code works for the RTC device, perhaps it may lead to sorting out what is missing when you attempt to use the IIC module.

 

Regards,

Mac

 

0 Kudos
Reply
2,173 Views
mylim
Contributor IV

Hi Bigmac,

Basing on your sample bit bang code, i tried it on  a MS9S08QE32 with a Freescale MPR121, from my scope i can see the tx is working but when rx i couldn't seem to get the value from the MPR121 touch sensor IC. 

I tested it with your code. Could you advise?

Thanks.

 

Regards,

MY

0 Kudos
Reply
2,173 Views
bigmac
Specialist III

Hello MY,

 

The linked communications protocol document for the MPR121 suggests that the 7-bit slave address value may be configured from the range $4C, $4D, $4E and $4F.  However, your code seems to select from the range $5A, $5B, 5C and $5D.   This may be the reason for the IIC slave not responding.

 

Regards,

Mac

 

0 Kudos
Reply
2,173 Views
mylim
Contributor IV

Hi bigmac, 

I found on this forum post https://community.freescale.com/message/62881#62881 that there are some errors in the datasheet. A friend of mine have tried that out and it works according to the address provided from that post. I also find that there are really lack of info provided for that part. haha.. Thanks.

 

Regards,

MY

0 Kudos
Reply
2,174 Views
RogerSchaefer
Contributor III

Thanks for the effort, Mac, but I really wanted to get the I2C module working.  I finally did after quite of bit of debuggin.

 

Anyone else want assembly code for the DS1307 clock chip I have it posted on my website:

http://www.rasmicro.com/DS1307.htm

 

Roger

0 Kudos
Reply