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 support@ccsinfo.com

pic18f252 i2c problem

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



Joined: 21 May 2008
Posts: 2

View user's profile Send private message MSN Messenger

pic18f252 i2c problem
PostPosted: Wed May 21, 2008 11:27 am     Reply with quote

Hello,
here I begin. I need assistance on a program I2C. I do not manage to program a clock real-time

Code:
////////pg///////

#include <18F452.h>


#use i2c(master,scl=pin_A5,sda=pin_A3)

byte const table[10]={0x00,0x08,0x04,0x03,0x0c,0x0b,0x0b,0x0b,0x0b,0x0b};
byte const table2[10]={0x0c,0x95,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1};
int i,h,m,ah,am,data,add;

///////////////////////////////////interrupt///////////////////////

#int_ext

void inter()
{
output_high(pin_B1);
}


////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
void write ()

{
   
i2c_start();
i2c_write(0xa0);
i2c_write(add);
i2c_write(data);
i2c_stop();
   
}

/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////

void config()

{

i=0;
add=table[i];
data=table2[i];
write();
i=i++;
add=table[i];
data=table2[i];
write();

}

///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
                                       
void regh()

{

i=i++;
add=table[i];
data=h;
write();
i=i++;
add=table[i];
data=m;
write();

}

////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////

void regalm()

{

i=i++;
add=table[i];
data=ah;
write();
i=i++;
add=table[i];
data=am;
write();

}

////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////

void main (void)

{
h=0x05; // test value
m=0x05;
ah=0x05;
am=0x06;
config();
regh();
regalm();
enable_interrupts(int_ext);
ext_int_edge(h_to_l);
sleep();

}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 21, 2008 12:03 pm     Reply with quote

Post the part number of the RTC chip.
benoit



Joined: 21 May 2008
Posts: 2

View user's profile Send private message MSN Messenger

PostPosted: Wed May 21, 2008 12:23 pm     Reply with quote

I use a pic18f252 a pcf8583. My problem it is that at exit of interuption of the clock I obtain a signal square.
I do not know where is my error.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 21, 2008 12:30 pm     Reply with quote

Quote:
I use a pcf8583

There is a driver for this RTC chip in the code library.
http://www.ccsinfo.com/forum/viewtopic.php?t=27988
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