Jump to content

MSP430G2335 Interfacing with a DS1307

Recommended Posts

For the past 4 hours I've been trying to troubleshoot a I2C communication between my MSP430G2335 and a DS1307 (powered from a external 5V PSU). This is the code I'm using (it uses alanbarr I2C library):

#include <msp430g2553.h>
#include "i2c.h"

void main() {
	BCSCTL1 = CALBC1_1MHZ;     // 1MHz clock.
	BCSCTL2 &= ~(DIVS_3);      // SMCLK = DCO = 1MHz.

	i2cTransmit(0, 1);
	char t[100];
	i2cReceive(t, 1); // Nothing. Just for testing.

The problem is that all I get is this:



Then apparently the CPU hangs (since nothing happens). So, anyone got any idea why that's happening? (by the way, yes, I have the 10k pullup resistors)


PS: It's 2am and I just rage quitted this, so you guys are my last hope.

Link to post
Share on other sites

One thinf i had to put in my code was a timeout fail because it would hang. If the slave module doesnt send ack bits consistently, the module can get confused and depending on how the code is written it will hang waiting for an event thats not gonna happen


Btw, based on your sda trace, there is no ack bit being sent (since the line is high until the stop command is sent)


Check your wiring, make sure its good

Link to post
Share on other sites

Please refer to this thread Problem with I2C RTC DS1307 Module at http://forum.43oh.com/topic/3872-problem-with-i2c-rtc-ds1307-module/


The DS1307 works at 5V while the MSP430 is 3.3V-based.


Add logic level converters or consider instead the 3.3V-based NXP PCF2129A. And check pull-up resistors.


Remember, the search box on this forum works very well :smile:

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...