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

Back to Subject List

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


 
#155493 - Interesting new LPC924 code problem
I'm creating an I2C interface from Code architect (in which I've used sucessfully in the past for other functions, not I2C), I plug in the my clock, tell it 100kHz and hit go. It generates the code no problem, now I tried to integrate it into the current project and it's giving all kinds of compile errors. So, I create a standalone virgin project and getting the same errors. It keeps creating undefined identifiers and I'm not sure why. I've combed the .h and .c files to see if the variable they generated was somehow commented out or the like. No such luck. I checked the reg924.h to see if it was supposed to use an SFR there, nothing matches.....hmmmm

I did a minimal approach of giving it a main, and programming of the GPIO pins. That is enough to get a compile out of it.

Typically if something needs to be added or changed the code will tell you. But I don't see anything. Here is the piece of the code and the errors listed in the build window:



/***********************************************************************
DESC:    I2C interrupt service routine. handles the transfer and
         calls the relevent callback functions. Changes mi2cstatus
RETURNS: Nothing
************************************************************************/
void i2c_isr
  (
  void
  ) interrupt 6 using 1
{
  unsigned char status;

  status = I2STAT & 0xF8;

  switch(status)
  {
    case 0x08:
    case 0x10:
      I2DAT = mslaveaddress;
      STA = 0;
      STO = 0;
      mbytenum = 0;
      break;

    // MASTER TRANSMITTER
    // ACK for slave address + W
    case 0x18:
      I2DAT = i2c_master_getbyte(mbytenum);
      STA = 0;
      STO = 0;
      break;
    // no ACK for slave address + W
    case 0x20:
      // stop condition
      STA = 0;
      STO = 1;
      mi2cstatus = I2C_ERROR;
      i2c_transfer_finished();
      break;
    // ACK for data byte
    case 0x28:
      if (i2c_master_islasttxbyte(mbytenum))
      {
        // stop condition
        STA = 0;
        STO = 1;
        mi2cstatus = I2C_OK;
        i2c_transfer_finished();
      }
      else
      {
        mbytenum++;
        I2DAT = i2c_master_getbyte(mbytenum);
        STA = 0;
        STO = 0;
      } // if
      break;
    // no ACK for data byte
    case 0x30:
      // stop condition
      STA = 0;
      STO = 1;
      mi2cstatus = I2C_ERROR;
      i2c_transfer_finished();
      break;
    // arbitration lost
    case 0x38:
      // start condition - try again
      STA = 1;
      STO = 0;
      break;


THESE ARE THE ERROR CODES




I2C.C(52): error C202: 'STA': undefined identifier
I2C.C(53): error C202: 'STO': undefined identifier
I2C.C(61): error C202: 'STA': undefined identifier
I2C.C(62): error C202: 'STO': undefined identifier
I2C.C(67): error C202: 'STA': undefined identifier
I2C.C(68): error C202: 'STO': undefined identifier
I2C.C(77): error C202: 'STA': undefined identifier
I2C.C(78): error C202: 'STO': undefined identifier
I2C.C(86): error C202: 'STA': undefined identifier
I2C.C(87): error C202: 'STO': undefined identifier
I2C.C(93): error C202: 'STA': undefined identifier
I2C.C(94): error C202: 'STO': undefined identifier
I2C.C(101): error C202: 'STA': undefined identifier
I2C.C(102): error C202: 'STO': undefined identifier
I2C.C(108): error C202: 'STA': undefined identifier
I2C.C(109): error C202: 'STO': undefined identifier
I2C.C(113): error C202: 'AA': undefined identifier
I2C.C(118): error C202: 'AA': undefined identifier
I2C.C(123): error C202: 'STA': undefined identifier
I2C.C(125): error C202: 'STO': undefined identifier
I2C.C(133): error C202: 'STA': undefined identifier
I2C.C(134): error C202: 'STO': undefined identifier
I2C.C(138): error C202: 'AA': undefined identifier
I2C.C(143): error C202: 'AA': undefined identifier
I2C.C(149): error C202: 'STA': undefined identifier
I2C.C(151): error C202: 'STO': undefined identifier
I2C.C(165): error C202: 'STA': undefined identifier
I2C.C(166): error C202: 'STO': undefined identifier
I2C.C(171): error C202: 'AA': undefined identifier
I2C.C(176): error C202: 'AA': undefined identifier
I2C.C(184): error C202: 'STA': undefined identifier
I2C.C(185): error C202: 'STO': undefined identifier
I2C.C(189): error C202: 'AA': undefined identifier
I2C.C(194): error C202: 'AA': undefined identifier
I2C.C(203): error C202: 'STA': undefined identifier
I2C.C(204): error C202: 'STO': undefined identifier
I2C.C(206): error C202: 'AA': undefined identifier
I2C.C(212): error C202: 'STA': undefined identifier
I2C.C(213): error C202: 'STO': undefined identifier
I2C.C(215): error C202: 'AA': undefined identifier
I2C.C(228): error C202: 'STA': undefined identifier
I2C.C(229): error C202: 'STO': undefined identifier
I2C.C(233): error C202: 'AA': undefined identifier
I2C.C(238): error C202: 'AA': undefined identifier
I2C.C(247): error C202: 'STA': undefined identifier
I2C.C(248): error C202: 'STO': undefined identifier
I2C.C(250): error C202: 'AA': undefined identifier
I2C.C(257): error C202: 'STA': undefined identifier
I2C.C(258): error C202: 'STO': undefined identifier
I2C.C(260): error C202: 'AA': undefined identifier
I2C.C(266): error C202: 'SI': undefined identifier
I2C.C(342): error C202: 'STA': undefined identifier
I2C.C(374): error C202: 'STA': undefined identifier
I2C.C(404): error C202: 'SI': undefined identifier


Now I've run into this before, and it always because I didn't identify a variable in a local function by accident/oversight. But these are defined nowhere and I believe it should have like it does for all the other modules it creates.


Would it be plausible that I'm supposed to define them as bytes? I see that they are being set to T or F conditions based on the case, but shouldn't they have been predefined?

If I start to add STA, AA, STO to the unsigned char line, obviously the errors go away, but is that was I'm supposed to do since it seems to clearly be changing a bit status flag and not an entire byte? I've done a watchdog, RS232, and ADC which is why I'm confused as to the problem I'm having here.

If someone has code architect, I did the following

Select lpc924 > I2C > Save and generate > file >> save target files.

that was it.

Thoughts?

thanks
chris

List of 6 messages in thread
TopicAuthorDate
Interesting new LPC924 code problem            01/01/70 00:00      
   Additional note            01/01/70 00:00      
      check reg924.h file            01/01/70 00:00      
   Go to the horse's mouth?            01/01/70 00:00      
      Actually that was a good place to start but...            01/01/70 00:00      
   the fact is ....            01/01/70 00:00      

Back to Subject List