chipKIT® Development Platform

Inspired by Arduino™

No way l2c library not working

Created Fri, 17 May 2019 17:57:07 +0000 by aldoz


aldoz

Fri, 17 May 2019 17:57:07 +0000

Hi all! I can't get working my code on my max32.

the problem is the use of the l2c library.

when I include that library I just get error.. No other libraries giving me errors; just the l2c!

Please help

here my code :

//========================================================================
// LASER

#define    LIDARLite_ADDRESS   0x62          // Default I2C Address of LIDAR-Lite.
#define    RegisterMeasure     0x00          // Register to write to initiate ranging.
#define    MeasureValue        0x04          // Value to initiate ranging.
#define    RegisterHighLowB    0x8f          // Register to get both High and Low bytes in 1 call.

#include "I2C.h"
#include "Arduino.h"

#include <Adafruit_PWMServoDriver.h>
// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();


//------------------------------------ ARRAY VISTA
byte array_vista[602];

//LASER PITCH
int SERVOMIN_las1 = 150;  //LASER PITCH
int SERVOMAX_las1 = 600;  //LASER PITCH
//LASER ROLL
int SERVOMIN_las2 = 150;  //LASER PITCH
int SERVOMAX_las2 = 600;  //LASER PITCH

//LASER
int pos_laserpitch_fin = 70; //70  diminuendo la testa picchia, aumentando cabra.
int pos_laserroll_fin = 40; //40       da 40 a 100 60°          da 25 a 115 campo visivo di 90°
int pos_laserroll_fin_now = 40;
int indice_vista = 0; //partira'da 0
int verso_scansione = 1; //1--> da sin a des  2--> da des a sin
int riga_scansione = 1;
int ok_scan = 1;
int numero_righe_raggiunto = 1;
int timer_las = 0;
int pulselengthlas1, pulselengthlas2;
int timer_k = 0;

// ================================================================
// ===                      INITIAL SETUP                       ===
// ================================================================

void setup() 
{
    //SET ARRAY VISTA
    for (int v = 0; v <= 602; v++)
    {
      array_vista[v] = 0;
    }

   //-----------------LASER SETUP
       Serial.begin(1000000); //Opens serial connection at 9600bps. 
       I2c.begin(); // Opens & joins the irc bus as master
       delay(100); // Waits to make sure everything is powered up before sending or receiving data  
       I2c.timeOut(50); // Sets a timeout to ensure no locking up of sketch if I2C communication fails

  
  pwm.begin();
  pwm.setPWMFreq(60);  // Analog servos run at ~60 Hz updates (STO USANDO SERVI A 125hz)
  go_servi();
}//fine void setup() 


void loop()
{
    //-----------------------------------------------------------------------------------------
  //-------------------------------------------------------- LASER
  //-----------------------------------------------------------------------------------------
  // Write 0x04 to register 0x00
  uint8_t nackack = 100; // Setup variable to hold ACK/NACK resopnses     
  while (nackack != 0)
  { // While NACK keep going (i.e. continue polling until sucess message (ACK) is received )
    nackack = I2c.write(LIDARLite_ADDRESS,RegisterMeasure, MeasureValue); // Write 0x04 to 0x00
    delay(1); // Wait 1 ms to prevent overpolling
  }

  byte distanceArray[2]; // array to store distance bytes from read function
  
  // Read 2byte distance from register 0x8f
  nackack = 100; // Setup variable to hold ACK/NACK resopnses     
  while (nackack != 0)
  { // While NACK keep going (i.e. continue polling until sucess message (ACK) is received )
    nackack = I2c.read(LIDARLite_ADDRESS,RegisterHighLowB, 2, distanceArray); // Read 2 Bytes from LIDAR-Lite Address and store in array
   delay(1); // Wait 1 ms to prevent overpolling
  }
  int distance = (distanceArray[0] << 8) + distanceArray[1];  // Shift high byte [0] 8 to the left and add low byte [1] to create 16-bit int
  //if (distance > 100){
  //  distance = 100;}

 
  //int pos_laserpitch_fin = 70;
  //int pos_laserroll_fin = 40;


  
  
 timer_k = timer_k + 1;
  
 if(timer_k > 250)
 {
  //int rs = 1
  //int pos_laserpitch_fin_val = 70
    //****************************** LASER PITCH
    if(riga_scansione == 1)
    {pos_laserpitch_fin = 70;} 
    if(riga_scansione == 2)
    {pos_laserpitch_fin = 65;} 
    if(riga_scansione == 3)
    {pos_laserpitch_fin = 60;} 
    if(riga_scansione == 4)
    {pos_laserpitch_fin = 55;} 
    if(riga_scansione == 5)
    {pos_laserpitch_fin = 50;}  
    if(riga_scansione == 6)
    {pos_laserpitch_fin = 45;}     
    if(riga_scansione == 7)
    {pos_laserpitch_fin = 40;}  
    if(riga_scansione == 8)
    {pos_laserpitch_fin = 35;}   
    if(riga_scansione == 9)
    {pos_laserpitch_fin = 30;}  
    if(riga_scansione == 10)
    {pos_laserpitch_fin = 25;}  

             //fare il grafico con le linee che mostrano i fasci laser
    //****************************** SCANSIONE VISTA DA SINISTRA A DESTRA
    if(ok_scan == 1)
    {
      if(verso_scansione == 1)// && pos_laserroll_fin <= 100) //da pos 40 a pos 100
      {            
           array_vista[indice_vista] = distance;

           pos_laserroll_fin = pos_laserroll_fin +1;
           indice_vista = indice_vista +1;       
           if(pos_laserroll_fin == 100)
           {
             verso_scansione = 2; //2--> da des a sin
             riga_scansione = riga_scansione + 1;
             numero_righe_raggiunto = numero_righe_raggiunto + 1;
           }
// ok miglior scansione laser di sempre 600pixels
          
      }//fine if(pos_laserroll_fin <= 100)
      else
      {
           array_vista[indice_vista] = distance;
       
           pos_laserroll_fin = pos_laserroll_fin -1;
           indice_vista = indice_vista +1;      
           if(pos_laserroll_fin == 40)
           {   
              verso_scansione = 1; //2--> da des a sin
              riga_scansione = riga_scansione + 1; 
              numero_righe_raggiunto = numero_righe_raggiunto + 1;
              if(numero_righe_raggiunto > 10)
              {
                indice_vista = 0;
                ok_scan = 0;
              }             
           }

               
      }

    }//fine if ok_scan = 1
   
 }//fine if(timer_k > 300)
go_servi();

for (int v = 0; v <= 599; v++) //fino a 59 = misurazioni prima riga / fino a 119 = misur.seconda riga / fino a 179 misur.terza riga / fino a 239 quarta mis. / fino a 299 quinta mis / fino a 359 sesta mis / fino a 419 settima / fino a 479 ottava/ fino a 539 nona/ fino a 599 decima 
{
 Serial.print(array_vista[v]);
 Serial.print(",");  
}
  
Serial.println();




}//FINE LOOP



void go_servi()
{
      //SETTAGGIO INIZIALE LASER PITCH
      pulselengthlas1 = map(pos_laserpitch_fin, 0, 180, SERVOMIN_las1, SERVOMAX_las1);
      pwm.setPWM(3, 0, pulselengthlas1);       

      //SETTAGGIO INIZIALE LASER ROLL
      pulselengthlas2 = map(pos_laserroll_fin, 0, 180, SERVOMIN_las2, SERVOMAX_las2);
      pwm.setPWM(7, 0, pulselengthlas2);    
}

and here the VERY LONG error message:

In file included from C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:63:0: C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp: In member function 'void I2C::begin()': C:\Program Files (x86)\Arduino\libraries\I2C\I2C.h:83:39: error: '_SFR_BYTE' was not declared in this scope #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:91:5: note: in expansion of macro 'sbi' sbi(PORTD, 0); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:95:7: error: 'TWSR' was not declared in this scope cbi(TWSR, TWPS0); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.h:82:36: note: in definition of macro 'cbi' #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) ^ In file included from C:\Users\aldo\AppData\Local\Arduino15\packages\chipKIT\hardware\pic32\2.0.5\cores\pic32/WProgram.h:9:0, from C:\Users\aldo\AppData\Local\Arduino15\packages\chipKIT\hardware\pic32\2.0.5\cores\pic32/Arduino.h:4, from C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:57: C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:95:13: error: 'TWPS0' was not declared in this scope cbi(TWSR, TWPS0); ^ C:\Users\aldo\AppData\Local\Arduino15\packages\chipKIT\hardware\pic32\2.0.5\cores\pic32/pins_arduino.h:51:27: note: in definition of macro '_BV' #define _BV(bit) (1ul << (bit)) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:95:3: note: in expansion of macro 'cbi' cbi(TWSR, TWPS0); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:96:13: error: 'TWPS1' was not declared in this scope cbi(TWSR, TWPS1); ^ C:\Users\aldo\AppData\Local\Arduino15\packages\chipKIT\hardware\pic32\2.0.5\cores\pic32/pins_arduino.h:51:27: note: in definition of macro '_BV' #define _BV(bit) (1ul << (bit)) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:96:3: note: in expansion of macro 'cbi' cbi(TWSR, TWPS1); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:97:3: error: 'TWBR' was not declared in this scope TWBR = ((F_CPU / 100000) - 16) / 2; ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:99:3: error: 'TWCR' was not declared in this scope TWCR = _BV(TWEN) | _BV(TWEA); ^ In file included from C:\Users\aldo\AppData\Local\Arduino15\packages\chipKIT\hardware\pic32\2.0.5\cores\pic32/WProgram.h:9:0, from C:\Users\aldo\AppData\Local\Arduino15\packages\chipKIT\hardware\pic32\2.0.5\cores\pic32/Arduino.h:4, from C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:57: C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:99:14: error: 'TWEN' was not declared in this scope TWCR = _BV(TWEN) | _BV(TWEA); ^ C:\Users\aldo\AppData\Local\Arduino15\packages\chipKIT\hardware\pic32\2.0.5\cores\pic32/pins_arduino.h:51:27: note: in definition of macro '_BV' #define _BV(bit) (1ul << (bit)) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:99:26: error: 'TWEA' was not declared in this scope TWCR = _BV(TWEN) | _BV(TWEA); ^ C:\Users\aldo\AppData\Local\Arduino15\packages\chipKIT\hardware\pic32\2.0.5\cores\pic32/pins_arduino.h:51:27: note: in definition of macro '_BV' #define _BV(bit) (1ul << (bit)) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp: In member function 'void I2C::end()': C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:104:3: error: 'TWCR' was not declared in this scope TWCR = 0; ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp: In member function 'void I2C::setSpeed(uint8_t)': C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:116:5: error: 'TWBR' was not declared in this scope TWBR = ((F_CPU / 100000) - 16) / 2; ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:120:5: error: 'TWBR' was not declared in this scope TWBR = ((F_CPU / 400000) - 16) / 2; ^ In file included from C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:63:0: C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp: In member function 'void I2C::pullup(uint8_t)': C:\Program Files (x86)\Arduino\libraries\I2C\I2C.h:83:39: error: '_SFR_BYTE' was not declared in this scope #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:136:7: note: in expansion of macro 'sbi' sbi(PORTD, 0); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.h:82:39: error: '_SFR_BYTE' was not declared in this scope #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:150:7: note: in expansion of macro 'cbi' cbi(PORTD, 0); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp: In member function 'uint8_t I2C::read(uint8_t, uint8_t)': C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:380:15: error: 'TWDR' was not declared in this scope data[i] = TWDR; ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp: In member function 'uint8_t I2C::read(uint8_t, uint8_t, uint8_t)': C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:445:15: error: 'TWDR' was not declared in this scope data[i] = TWDR; ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp: In member function 'uint8_t I2C::read(uint8_t, uint8_t, uint8_t*)': C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:487:21: error: 'TWDR' was not declared in this scope dataBuffer[i] = TWDR; ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp: In member function 'uint8_t I2C::read(uint8_t, uint8_t, uint8_t, uint8_t*)': C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:547:21: error: 'TWDR' was not declared in this scope dataBuffer[i] = TWDR; ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp: In member function 'uint8_t I2C::start()': C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:567:3: error: 'TWCR' was not declared in this scope TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:567:14: error: 'TWINT' was not declared in this scope TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:567:25: error: 'TWSTA' was not declared in this scope TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:567:36: error: 'TWEN' was not declared in this scope TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN); ^ In file included from C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:63:0: C:\Program Files (x86)\Arduino\libraries\I2C\I2C.h:79:26: error: 'TWSR' was not declared in this scope #define TWI_STATUS (TWSR & 0xF8) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:578:8: note: in expansion of macro 'TWI_STATUS' if ((TWI_STATUS == START) || (TWI_STATUS == REPEATED_START)) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.h:79:26: error: 'TWSR' was not declared in this scope #define TWI_STATUS (TWSR & 0xF8) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:582:7: note: in expansion of macro 'TWI_STATUS' if (TWI_STATUS == LOST_ARBTRTN) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.h:79:26: error: 'TWSR' was not declared in this scope #define TWI_STATUS (TWSR & 0xF8) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:588:10: note: in expansion of macro 'TWI_STATUS' return(TWI_STATUS); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp: In member function 'uint8_t I2C::sendAddress(uint8_t)': C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:593:3: error: 'TWDR' was not declared in this scope TWDR = i2cAddress; ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:595:3: error: 'TWCR' was not declared in this scope TWCR = (1<<TWINT) | (1<<TWEN); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:595:14: error: 'TWINT' was not declared in this scope TWCR = (1<<TWINT) | (1<<TWEN); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:595:27: error: 'TWEN' was not declared in this scope TWCR = (1<<TWINT) | (1<<TWEN); ^ In file included from C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:63:0: C:\Program Files (x86)\Arduino\libraries\I2C\I2C.h:79:26: error: 'TWSR' was not declared in this scope #define TWI_STATUS (TWSR & 0xF8) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:606:8: note: in expansion of macro 'TWI_STATUS' if ((TWI_STATUS == MT_SLA_ACK) || (TWI_STATUS == MR_SLA_ACK)) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.h:79:26: error: 'TWSR' was not declared in this scope #define TWI_STATUS (TWSR & 0xF8) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:610:28: note: in expansion of macro 'TWI_STATUS' uint8_t bufferedStatus = TWI_STATUS; ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp: In member function 'uint8_t I2C::sendByte(uint8_t)': C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:625:3: error: 'TWDR' was not declared in this scope TWDR = i2cData; ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:627:3: error: 'TWCR' was not declared in this scope TWCR = (1<<TWINT) | (1<<TWEN); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:627:14: error: 'TWINT' was not declared in this scope TWCR = (1<<TWINT) | (1<<TWEN); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:627:27: error: 'TWEN' was not declared in this scope TWCR = (1<<TWINT) | (1<<TWEN); ^ In file included from C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:63:0: C:\Program Files (x86)\Arduino\libraries\I2C\I2C.h:79:26: error: 'TWSR' was not declared in this scope #define TWI_STATUS (TWSR & 0xF8) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:638:7: note: in expansion of macro 'TWI_STATUS' if (TWI_STATUS == MT_DATA_ACK) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.h:79:26: error: 'TWSR' was not declared in this scope #define TWI_STATUS (TWSR & 0xF8) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:642:28: note: in expansion of macro 'TWI_STATUS' uint8_t bufferedStatus = TWI_STATUS; ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp: In member function 'uint8_t I2C::receiveByte(uint8_t)': C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:660:5: error: 'TWCR' was not declared in this scope TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWEA); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:660:16: error: 'TWINT' was not declared in this scope TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWEA); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:660:29: error: 'TWEN' was not declared in this scope TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWEA); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:660:41: error: 'TWEA' was not declared in this scope TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWEA); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:665:5: error: 'TWCR' was not declared in this scope TWCR = (1<<TWINT) | (1<<TWEN); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:665:16: error: 'TWINT' was not declared in this scope TWCR = (1<<TWINT) | (1<<TWEN); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:665:29: error: 'TWEN' was not declared in this scope TWCR = (1<<TWINT) | (1<<TWEN); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:667:12: error: 'TWCR' was not declared in this scope while (!(TWCR & (1<<TWINT))) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:667:23: error: 'TWINT' was not declared in this scope while (!(TWCR & (1<<TWINT))) ^ In file included from C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:63:0: C:\Program Files (x86)\Arduino\libraries\I2C\I2C.h:79:26: error: 'TWSR' was not declared in this scope #define TWI_STATUS (TWSR & 0xF8) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:676:7: note: in expansion of macro 'TWI_STATUS' if (TWI_STATUS == LOST_ARBTRTN) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.h:79:26: error: 'TWSR' was not declared in this scope #define TWI_STATUS (TWSR & 0xF8) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:682:10: note: in expansion of macro 'TWI_STATUS' return(TWI_STATUS); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp: In member function 'uint8_t I2C::stop()': C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:688:3: error: 'TWCR' was not declared in this scope TWCR = (1<<TWINT)|(1<<TWEN)| (1<<TWSTO); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:688:14: error: 'TWINT' was not declared in this scope TWCR = (1<<TWINT)|(1<<TWEN)| (1<<TWSTO); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:688:25: error: 'TWEN' was not declared in this scope TWCR = (1<<TWINT)|(1<<TWEN)| (1<<TWSTO); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:688:36: error: 'TWSTO' was not declared in this scope TWCR = (1<<TWINT)|(1<<TWEN)| (1<<TWSTO); ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp: In member function 'void I2C::lockUp()': C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:704:3: error: 'TWCR' was not declared in this scope TWCR = 0; //releases SDA and SCL lines to high impedance ^ In file included from C:\Users\aldo\AppData\Local\Arduino15\packages\chipKIT\hardware\pic32\2.0.5\cores\pic32/WProgram.h:9:0, from C:\Users\aldo\AppData\Local\Arduino15\packages\chipKIT\hardware\pic32\2.0.5\cores\pic32/Arduino.h:4, from C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:57: C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:705:14: error: 'TWEN' was not declared in this scope TWCR = _BV(TWEN) | _BV(TWEA); //reinitialize TWI ^ C:\Users\aldo\AppData\Local\Arduino15\packages\chipKIT\hardware\pic32\2.0.5\cores\pic32/pins_arduino.h:51:27: note: in definition of macro '_BV' #define _BV(bit) (1ul << (bit)) ^ C:\Program Files (x86)\Arduino\libraries\I2C\I2C.cpp:705:26: error: 'TWEA' was not declared in this scope TWCR = _BV(TWEN) | _BV(TWEA); //reinitialize TWI ^ C:\Users\aldo\AppData\Local\Arduino15\packages\chipKIT\hardware\pic32\2.0.5\cores\pic32/pins_arduino.h:51:27: note: in definition of macro '_BV' #define _BV(bit) (1ul << (bit)) ^ exit status 255 Errore durante la compilazione per la scheda chipKIT MAX32.


majenko

Sat, 18 May 2019 09:44:42 +0000

That's an Arduino library, not a chipKIT library. It can only work on Arduino boards because it directly interfaces with the registers in the AVR chip on the Arduino.

Instead you should either use the Wire library (simple interface) or the DTWI library (complex interface but far more powerful).


aldoz

Sat, 18 May 2019 10:57:16 +0000

That's an Arduino library, not a chipKIT library. It can only work on Arduino boards because it directly interfaces with the registers in the AVR chip on the Arduino. Instead you should either use the Wire library (simple interface) or the DTWI library (complex interface but far more powerful).

Thank you very mutch majenko! Yeah, I will use wire library and sure I will take a look on DTWI library too!

Thank you again!