Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8518811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:05:16+00:00 2026-06-11T06:05:16+00:00

I’m having problems with the I2C module on the PIC24HJ256GP610A. My code (see snippet

  • 0

I’m having problems with the I2C module on the PIC24HJ256GP610A. My code (see snippet below) runs perfectly fine on the PIC24HJ256GP610 [note: not 610A]. I’m using the I2C bus for communicating with a DS1374 RTCC. But on the 610A, it gets stuck when polling the ACKSTAT bit when trying to write a value to the RTCC with I2C. Also, most of the time the RTCC value does not increment when reading the value via I2C (sometimes it does increment as it should). Any ideas? Is there a config bit/mode/setting difference between the 610 and 610A that deals with the I2C module? I’ve tried switching out the RTCC chip, and switching out processors. So, the only difference here is that the I2C communication works on the 610, and not on the 610A.

What are the differences between the 610 and 610A? Is the 610 an obsolete part that is no longer manufactured, or will it keep being manufactured?

A few things I’ve noticed when experimenting, probing the signals, and stepping through with the debugger:

1). The I2C clock goes high indefinitely on the to-be 20th transmitted bit, which is where it gets stuck polling the ACKSTAT bit if I pause the debugger. The first bit appears to be the start bit, then 9 more bits, then another start/stop bit, then 9 more bits, then the clock line goes high.

2). When the clock line gets stuck and using the watch window, the value in the I2C1STATbits register is 0x8008, which translates to received a NACK from the slave device, and that a Start (or Repeated Start) bit has been detected last.

3). I am always able to read from the slave device (RTCC) with both 610 and 610A. However, sometimes with the 610A its value does not increment and stays at some integer value. I believe when I cut off power to everything and reprogram everything, the RTCC value changes. Sometimes it stays constant when reading the value, and maybe 25% of the time it actually changes as it should when reading its value.

4). I am not able to write anything to the RTCC via I2C using the 610A. The processor gets stuck polling the ACKSTAT bit (I assume because it received a NACK from the RTCC.) The 610 works perfect.

Tools: MPLAB v8.86, C30 v3.31, ICD3

Thank you,
Brad

//Write RTCC Register: This functions writes a Byte to the DS1374 RTCC
void Write_RTCC_Register(int Register, unsigned char Byte
{
    unsigned int config2, config1;
    /* Baud rate is set for 100 Khz */
    config2 = 0x97;
    /* Configure I2C for 7 bit address mode */
    config1 =  (I2C1_ON & I2C1_IDLE_CON & I2C1_CLK_HLD &
            I2C1_IPMI_DIS & I2C1_7BIT_ADD &
            I2C1_SLW_DIS & I2C1_SM_DIS &
            I2C1_GCALL_DIS & I2C1_STR_DIS &
            I2C1_NACK & I2C1_ACK_DIS & I2C1_RCV_DIS &
            I2C1_STOP_DIS & I2C1_RESTART_DIS &
            I2C1_START_DIS);

OpenI2C1(config1,config2);
IdleI2C1();
StartI2C1();

//Configure RTCC
//Wait till Start sequence is completed
while(I2C1CONbits.SEN);
//Clear interrupt flag
IFS1bits.MI2C1IF = 0;
//Write Slave address and set master for transmission
MasterWriteI2C1(0xD0);
//Wait till address is transmitted
while(I2C1STATbits.TBF);  // 8 clock cycles
while(!IFS1bits.MI2C1IF); // Wait for 9th clock cycle
IFS1bits.MI2C1IF = 0;     // Clear interrupt flag 
while(I2C1STATbits.ACKSTAT);            

OpenI2C1(config1,config2);
IdleI2C1();
StartI2C1();
//Wait till Start sequence is completed
while(I2C1CONbits.SEN);

//Clear interrupt flag
IFS1bits.MI2C1IF = 0;
//Write Slave address and set master for transmission
MasterWriteI2C1(Register);

//Wait till address is transmitted
while(I2C1STATbits.TBF);  // 8 clock cycles
while(!IFS1bits.MI2C1IF); // Wait for 9th clock cycle

IFS1bits.MI2C1IF = 0;     // Clear interrupt flag

***while(I2C1STATbits.ACKSTAT); //problem here***


//Clear interrupt flag
IFS1bits.MI2C1IF = 0;
//Write Slave address and set master for transmission
MasterWriteI2C1(Byte);
//Wait till address is transmitted
while(I2C1STATbits.TBF);  // 8 clock cycles
while(!IFS1bits.MI2C1IF); // Wait for 9th clock cycle
IFS1bits.MI2C1IF = 0;     // Clear interrupt flag 
while(I2C1STATbits.ACKSTAT);

StopI2C1();
//Wait till stop sequence is completed
while(I2C1CONbits.PEN);
CloseI2C1();
}; //Write RTCC Register
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:05:17+00:00Added an answer on June 11, 2026 at 6:05 am

    I found the issue. I was re-enabling the I2C module, and asserting an unnecessary start condition several lines above the “…ACKSTAT); //problem here” line of code. The re-enabling of the module doesn’t appear to make a difference, it was the re-assertion of the start condition bit that was the issue.

    I’m not sure why it would work with the 610 and not the 610A. Regardless, problem solved!

    ...
    ...
    ...
    //**DELETED** OpenI2C1(config1,config2);
    //**DELETED** IdleI2C1();
    //**DELETED** StartI2C1();
    ////**DELETED** Wait till Start sequence is completed
    //**DELETED** while(I2C1CONbits.SEN);
    
    //Clear interrupt flag
    IFS1bits.MI2C1IF = 0;
    //Write Slave address and set master for transmission
    MasterWriteI2C1(Register);
    
    //Wait till address is transmitted
    while(I2C1STATbits.TBF);  // 8 clock cycles
    while(!IFS1bits.MI2C1IF); // Wait for 9th clock cycle
    
    IFS1bits.MI2C1IF = 0;     // Clear interrupt flag
    
    while(I2C1STATbits.ACKSTAT); // ** problem no more!
    ...
    ...
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.