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

I2C problem

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



Joined: 10 Aug 2007
Posts: 7

View user's profile Send private message

I2C problem
PostPosted: Thu Nov 29, 2007 2:00 pm     Reply with quote

Hi, I am French, sorry for my English.
I have a problem with I2C. I have two PIC 18F452 and an EEPROM 24C1025. The two PIC are MULTI_MASTER.
The first PIC write a data in EEPROM at address 0X00 and the second PIC read the data at address 0X00 then display. I use the CCS driver 241025.C
If I play each PIC the result is OK but if I play with two PIC the value display is not correct and in the EEPROM there are more values.
Now if I remove the EEPROM some values are display. It is strange.
My question: it is possible to write in the EEPROM with a PIC and to read the data with another PIC.
If anyone have an ideas
Thanks for your answers.

WRITE
Code:

//******************************************************************************
//*                               NOPNOP II V2.0                               *
//*                                   Write                                    *
//******************************************************************************

#include <18F452.h>

#fuses NOWDT,WDT128,HS, NOPROTECT, NOOSCSEN, BROWNOUT, BORV20, PUT, STVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOWRTB, NOWRTC, NOCPD, NOCPB, NOEBTR, NOEBTRB
#use delay(clock=20000000)
#use i2c(MULTI_MASTER, SCL=PIN_C3, SDA=PIN_C4, FAST, FORCE_HW)

#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
#use fast_io(D)
#use fast_io(E)

#include <241025.c>

//******************************************************************************
//*                             CONSTANTES                                     *
//******************************************************************************
int8 vData1;
int vStart;
//******************************************************************************
//*                          Programme principal                               *
//******************************************************************************

void main()
{
   //**************************************************
   //*                  Variables                     *
   //**************************************************

   //**************************************************
   //*         PARAMETRE DES PORTS DU PIC             *
   //**************************************************
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_wdt(WDT_OFF);
   
   enable_interrupts(GLOBAL);
 
   output_A(0);
   output_B(0);
   output_C(0);
   output_E(0);
   set_tris_A(0b00000001);
   set_tris_B(0b10111111);
   set_tris_C(0b10111011);
   set_tris_E(0b00000100);


   //**************************************************
   //*                                                *
   //**************************************************
//init_ext_eeprom();
vData1=0x10;
   
   while(true)
   {
      write_ext_eeprom(0x00,vData1++);
   }
}


READ
Code:

//******************************************************************************
//*                               NOPNOP II V2.0                               *
//*                                    Read                                    *
//******************************************************************************
#include <18F452.h>

#fuses NOWDT,WDT128,HS, NOPROTECT, NOOSCSEN, BROWNOUT, BORV20, PUT, STVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOWRTB, NOWRTC, NOCPD, NOCPB, NOEBTR, NOEBTRB
#use delay(clock=20000000)
#use i2c(MULTI_MASTER, SCL=PIN_C3, SDA=PIN_C4, FAST, FORCE_HW)

#include <LCD_nopnop.C>
#include <241025.C>
#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
#use fast_io(D)
#use fast_io(E)

#define portA 0xF80
#define bStart   *portA,0  // flag de demarrage provenant du PIC TIMER

//******************************************************************************
//*                             CONSTANTES                                     *
//******************************************************************************

//******************************************************************************
//*                            PROCEDURES                                      *
//******************************************************************************

//******************************************************************************
//*                          Programme principal                               *
//******************************************************************************

void main()
{
   //**************************************************
   //*                  Variables                     *
   //**************************************************

   //**************************************************
   //*         PARAMETRE DES PORTS DU PIC             *
   //**************************************************
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_wdt(WDT_OFF);

   enable_interrupts(GLOBAL);

   output_A(0);
   output_B(0);
   output_C(0);
   output_E(0);
   set_tris_A(0b00000001);
   set_tris_B(0b10111111);
   set_tris_C(0b10111011);
   set_tris_E(0b00000100);

   //**************************************************
   //*              INITIALISATIONS                   *
   //**************************************************
//   init_ext_eeprom();
   lcd_init();    // Init ecran LCD

   //**************************************************
   //*                                                *
   //**************************************************
   
   lcd_gotoxy(1,1);
   lcd_putc("                ");
   lcd_gotoxy(1,2);
   lcd_putc("                ");     
   lcd_gotoxy(6,1);
   lcd_putc("Start !");
   delay_ms(500);
   lcd_gotoxy(1,1);
   lcd_putc("                ");     
   while(true)
   {
      lcd_gotoxy(1,1);
      lcd_putc("        ");
      lcd_gotoxy(1,1);
      printf(LCD_PUTC,"%d",read_ext_eeprom(0x00));
   }
}

_________________
made by www.nopnop.fr
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