CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Can't write (or read) byte to MCP79411

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
JerryR



Joined: 07 Feb 2008
Posts: 196

View user's profile Send private message

Can't write (or read) byte to MCP79411
PostPosted: Wed Nov 04, 2026 8:17 am     Reply with quote

Hello group:

Hope someone can help me with this issue.

I'm using PCWH v5.121 and the driver for the MCP79411 as published in the code library. Excellent work by Daniel Pechmann !

I'm attempting to adjust the ADR_CAL register (0x08) without success. Time functions all work correctly, however. It appears that I can't either read or write to any particular register. After a write, I always receive 0xA5.

As far as hardware, pretty typical. 2.2Kohm pull-ups on both SDA and SCK lines. No other devices share the I2C port. Using hardware I2C port on PIC16F1619.

Here's the test code:

Code:


//updated version v2.0

#include <16f1619.h>

#use delay(clock=16000000)


#include <MCP79411_driver.c>
#fuses HS                     //high speed external crystal
#fuses NOWDT, NOPLLEN, NOPROTECT, NOLVP, NOBROWNOUT

//===========================================================================

void main(void)
{
int8  Trim_Val;

//initialize RTCC
rtc_Init();


Trim_Val= rtc_read_byte(ADDR_CAL);
rtc_write_byte(ADDR_CAL, 0x1C);
Trim_Val= rtc_read_byte(ADDR_CAL);
delay_us(1);

 while(TRUE)
   {

   
     
   }
}



Using I2C setup in driver file:

Code:

#use i2c(master, sda=RTC_SDA, scl=RTC_SCL, FAST=400000)


Using unmolested MCP79411_driver.c file.

Any help would be most appreciated. THANKS
Ttelmah



Joined: 11 Mar 2010
Posts: 20152

View user's profile Send private message

PostPosted: Wed Nov 04, 2026 12:27 pm     Reply with quote

An issue straight away. The rtc_read_byte function is for reading the
rtc registers, which are BCD coded. Not a binary register like the calibration
one. To read the value from that you'd need to code your own version
of the read function without the bcd conversions. May not be the problem
but needs to be fixed.
JerryR



Joined: 07 Feb 2008
Posts: 196

View user's profile Send private message

PostPosted: Wed Nov 04, 2026 12:50 pm     Reply with quote

Hi Ttelmah:

Yes, understand that, so not an issue to retrieve non BCD data. However, polling any register with this code returns 0xA5. I'm wondering if I'm actually setting correct information in a register with the write byte routines, but not reading a register correctly.

Can't believe no one has ever noticed this before.

Thanks for your help
JerryR



Joined: 07 Feb 2008
Posts: 196

View user's profile Send private message

PostPosted: Wed Nov 04, 2026 3:44 pm     Reply with quote

Hi Ttelmah:

Solved:

Yes, you were certainly right that reads, as his code provided, were converted to BCD. However, both reads and writes were addressing the EEPROM region in the MCP79411, not the SRAM/RTCC region as I required to write to.

Simply closely examining the data sheet and writing my own code to address the SRAM/RTCC area fixed the issue. Thanks for your kind assistance.

All the best
Ttelmah



Joined: 11 Mar 2010
Posts: 20152

View user's profile Send private message

PostPosted: Thu Nov 05, 2026 1:58 am     Reply with quote

Well done. I didn't know this chip, but looking at the code spotted the
BCD conversion, so thought I'd point that out.
Separately, though it defaults to 0, I'd probably explicitly clear the multiplier
bit in the control register, just to 'make sure'......
Flag the thread as solved please.

Recently CCS has been the subject of a rather heavy DOS attack, and
this forum was caught in the periphery of this. Hopefully they seem to be
getting on top of this and things should be going back to normal.
JerryR



Joined: 07 Feb 2008
Posts: 196

View user's profile Send private message

Solved
PostPosted: Thu Nov 05, 2026 8:19 am     Reply with quote

Thanks Ttelmah.

Yes, will follow up as you suggest.

Also saw the DOS on the forum website. I don't see what they get from doing this and I'm sorry it has been an issue on such a valuable resource.

Again, many thanks for your interest and keep up you valuable work.
Ttelmah



Joined: 11 Mar 2010
Posts: 20152

View user's profile Send private message

PostPosted: Fri Nov 06, 2026 1:16 am     Reply with quote

The point about 'flagging as solved', is that as the thread creator, edit the title,
so it has [solved] in it. You have to do this. Others can't.

On the DOS, it was CCS themselves that had the biggest hit. The forum
sort of just got caught as a link from the CCS site. Probably just an idiot
playing with an AI (it is possible now to do quite powerful DOS attacks
using these). If it was a DDOS attack (lots of sources), it may possibly
have been done using an automated script Why?. I don't know if there
is an answer. Why do people commit vandalism is a similar question..... Sad
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group