Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/14/08 14:14
Read: times


 
#159051 - I need baby steps now. I 'm staying crazy with it.
Responding to: ???'s previous message
Hi ,

You tell me in the second message what code I have to added it. I created a global var named unsigned char i2cVector[30]; And created also two more variables unsigned int: IndexTx and IndexRx, to pointed to correct variable position.

In the Callback rotines, I did it:



unsigned char i2c_master_getbyte(unsigned int bytenum)
{
    return i2cVector[bytenum];
}

void i2c_master_receivedbyte(unsigned int bytenum, unsigned char value)
{
  i2cVector[bytenum]=value;
}

unsigned char i2c_master_islasttxbyte(unsigned int bytenum)
{
  if(bytenum==(IndexTx-1))
    return(1);
  else
    return(0);
}

unsigned char i2c_master_islastrxbyte(unsigned int bytenum)
{
  if(bytenum==(IndexRx-1))
    return(1);
  else
    return(0);
}

void i2c_transfer_finished(void)
{
  IndexTx=0;
  IndexRx=0;
}

I didn't change anything in the others functions.
Are anything correct code ?

Now, I'm trying to write a byte using :


#define AT24C256 0x50	// 0101 0000

void main(void)
{
  i2c_init(0x00, 0);
  EA=1;
  IndexTx=3;   // bytes to write to memory
  i2cVector[0]=0x00;
  i2cVector[1]=0x00;
  i2cVector[2]=0x5A;
  while(1)
  {
     if (i2c_getstatus() == I2C_OK)
       i2c_transmit(AT24C256);
     IndexRx=1;  // bytes to read from memory
     if (i2c_getstatus() == I2C_OK)
       i2c_receive(AT24C256);
  }
  while(1);
}


Are these anything correct code?

I undestood how the I2C interrupt work. The I2C interrupt is called a lot of time to transmit a sigle byte. (start condition, putting address slave in i2c bus, putting address e2prom (high and low), putting data to write and finally, stop condition.

Is it correct ?

Jorge

List of 51 messages in thread
TopicAuthorDate
Question about I2C code from Code Architect            01/01/70 00:00      
   these functions are like...            01/01/70 00:00      
      Some functions are not necessary ...            01/01/70 00:00      
         yes            01/01/70 00:00      
            Question about I2C (again)            01/01/70 00:00      
               do not fiddle with the SFRs            01/01/70 00:00      
            I2C and code architect            01/01/70 00:00      
               problens with I2C            01/01/70 00:00      
                  what tools do you have?            01/01/70 00:00      
                     Tools            01/01/70 00:00      
                        try smaller resistors            01/01/70 00:00      
                           I2C Code            01/01/70 00:00      
                              Update            01/01/70 00:00      
                              I2C Code            01/01/70 00:00      
   Problens in I2C            01/01/70 00:00      
   The code            01/01/70 00:00      
      other board, same problem            01/01/70 00:00      
         I do not recall, but have a look            01/01/70 00:00      
            Shifted            01/01/70 00:00      
               Issues            01/01/70 00:00      
                  Ok..more questions.            01/01/70 00:00      
                     I2C            01/01/70 00:00      
                        How to write ?            01/01/70 00:00      
   Always get IDLE status in I2C bus            01/01/70 00:00      
   Always get IDLE status in I2C bus            01/01/70 00:00      
      I2C Interrupt doesn't work.            01/01/70 00:00      
   HOW CAN I TEST I2C INTERRUPT?            01/01/70 00:00      
      It seems to me that ....            01/01/70 00:00      
         ok, I removed spy from I2C int            01/01/70 00:00      
            some code            01/01/70 00:00      
               I need baby steps now. I 'm staying crazy with it.            01/01/70 00:00      
                  getting less crazy            01/01/70 00:00      
   where is            01/01/70 00:00      
      I couldn't understand            01/01/70 00:00      
         things            01/01/70 00:00      
         Misunderstanding            01/01/70 00:00      
            if you have ICE or ...            01/01/70 00:00      
         Code            01/01/70 00:00      
   Your note to me            01/01/70 00:00      
   Baby steps again - I2C, the return            01/01/70 00:00      
      Understanding            01/01/70 00:00      
         Because...            01/01/70 00:00      
            Hmmm            01/01/70 00:00      
                I can see something finally !!!            01/01/70 00:00      
                  Breadboard            01/01/70 00:00      
                     solder joints            01/01/70 00:00      
                        by checking EVERY solder joint twice.            01/01/70 00:00      
   I checked all solder joint            01/01/70 00:00      
      look in the datasheet and find out how to make ...            01/01/70 00:00      
         I didn't get yet            01/01/70 00:00      
            Anyone?            01/01/70 00:00      

Back to Subject List