Need help with RTC DS3231 and PIC16F690

Thread Starter

Fossil_hunter

Joined Nov 19, 2020
4
Hi

I am trying to make an alarm clock with a PIC16F690 and DS3231 RTC which displays on four SSDs. I am using the following link to do it since it is a similar configuration I am trying to use.

https://forum.allaboutcircuits.com/threads/i2c-pic16f690-and-rtc-ds3231-help.97156/

I used the same functions except I have added a display and delay function. I have tried changing the code many times but it still returns 0xFF. In the link, the individual mentions that the address was the problem but I have went through datasheets and found that the address to be used is 0x68 (which is used in the individuals code). I am programming in assembly language.
 

Thread Starter

Fossil_hunter

Joined Nov 19, 2020
4
I looked up the data sheet for the DS3231 and it said the address was 0xD0. It was on page 16 in this document:

https://datasheets.maximintegrated.com/en/ds/DS3231M.pdf
Thanks for the reply John

In the software, the address 0x68 is rotated to the left to give the address 0xD0 or 1101 000. Thereafter, a 0 or 1 is put in the end of the address depending if it is a read or write.

Do you think the address is being sent wrong or this could be a banking issue?
 

Deleted member 115935

Joined Dec 31, 1969
0
the common problems with I2C,

lack of pull ups, check with a scope
lack of VoH / VoL on the lines, check with a scope
bad edges on lines, check with scope,
bad timing on lines, check with scope
back to front data / start / stop , check with scope

wrong address, use a I2C scanning routing to see if you get an ack on the correct address
a scope is helpful
 

sagor

Joined Mar 10, 2019
902
Not a PIC answer, but there are Arduino sketches that scan the I2C bus and return all the addresses found. Very useful to verify/find any address of any I2C device. Easy to do with a small Arduino Nano, the free Arduino software and a couple of wires. Total cost is a few dollars to have a tool that finds I2C addresses of devices.

Otherwise, it could be your code and/or timing issues.
 

Thread Starter

Fossil_hunter

Joined Nov 19, 2020
4
Hi everyone
Thanks for the help.

After several hours of debugging, I finally got it right. I built the exact circuit in Proteus then tested my code with the use of the oscilloscope in Proteus. I can now see the time. However, I'm not sure what I am doing wrong but I cannot use other functions in the project. For example, if I want to set the time for the alarm using buttons and no buttons are pressed so the current time is displayed, it displays random signs on the SSDs. How can I overcome this?

Thanks in advance.
 

ErnieM

Joined Apr 24, 2011
8,377
There is no minimum speed for I2C. This means you could manually throw switches (debounced, of course) to set the clock and data lines.

By doing so you can check the ACK bit with a meter. No 'scope required!
 

Thread Starter

Fossil_hunter

Joined Nov 19, 2020
4
There is no minimum speed for I2C. This means you could manually throw switches (debounced, of course) to set the clock and data lines.

By doing so you can check the ACK bit with a meter. No 'scope required!
Hi ErnieM

Do you have any links that show how to do this method? As I am still new to using I2C communication.

Thanks
 

ErnieM

Joined Apr 24, 2011
8,377
Can you make a debounced signal? If so, just Simon Sez how the data sheet says to address your device using open collector drivers and pull-ups. Monitor the data line with a multimeter to see what the data line for ACK says.
 
Last edited:
Top