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

Back to Subject List

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


 
#159388 - I didn't get yet
Responding to: ???'s previous message
Hi,

I could't write or read e2prom yet. I know, it's a shame for me.
I was following the program line by line. I thought the written was ok, but I'was wrong.

I understood how the i2c works, and following the i2c interrupt, it must work. The variable mbytenum is increased by interrupt code.

In the i2c interrupt , I put this: P1&=0xEF; to follow the execution. But it is not executed. Then my program stay waiting, but the i2c bus in oscilloscope has activity.

Should you say me what is the problem ?


This is my code:

#include <reg952.h>
#include "uart.c"
#include "i2c_callback.c"
#include "i2c.c"

#define address 0x0000
#define M24C01 0x50	// 0101 0000
void main(void)
{
  P1M1 &= 0xEF;
  P1M1 |= 0x20;
  P1M2 &= 0xDF;
  P1M2 |= 0x10;
  P1 |= 0x10;  // putting P1.4=1
  i2c_init(0x00, 0);
  EA=1;

  i2cVector[0]=(unsigned char)((address&0xFF00)>>8);
  i2cVector[1]=(unsigned char)(address&0xFF);
  i2cVector[2]=0x5A;

  i2cIndex=3;	// number of bytes to be transmited/received
  i2c_transmit(M24C01);	// send peripherical address
  while(i2c_getstatus() & I2C_BUSY);// wait to finish
  
  while(1);
}

// interrupt
  
// ACK for data byte
    case 0x28:
      if (i2c_master_islasttxbyte(mbytenum))  // only verify if byte is the last
      {
        // stop condition
        STA = 0;
        STO = 1;
        mi2cstatus = I2C_OK;
        i2c_transfer_finished();
	P1&=0xEF;  // This is NOT  work !
      }
      else
      {
        mbytenum++;
        I2DAT = i2c_master_getbyte(mbytenum);
        STA = 0;
        STO = 0;
      } // if

      break;

thanks

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