Created Wed, 11 Nov 2015 20:01:32 +0000 by ahurley
Wed, 11 Nov 2015 20:01:32 +0000
Hello,
I am trying to use a library called SoftI2CMaster for the Repeat Start function for a sensor I am working with. Here is the link: [url]https://github.com/felias-fogg/SoftI2CMaster[/url]. I have tried to compile the following code with the libray imported into MPIDE 0023 20140821 and Arduino 1.6.5 with ChipKit Core installed in the hardware directory.
Here are my questions:
#include <SoftI2CMaster.h>
#define SDA_PIN 20
#define SDA_PORT PORTA
#define SCL_PIN 21
#define SCL_PORT PORTA
void setup()
{
}
void loop()
{
}
The only thing I did to the SoftI2CMaster.h file was excluding this:
//#include <avr/io.h>
//#include <Arduino.h>
Here are the errors I got in compiling:
Arduino: 1.6.5 (Windows XP), Board: "chipKIT MAX32"
Using library SoftI2CMaster-master in folder: C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master (legacy)
C:\Program Files\Arduino\hardware\chipkit-core/pic32/compiler/pic32-tools/bin/pic32-g++ -O2 -c -mno-smart-io -w -fno-exceptions -ffunction-sections -fdata-sections -G1024 -g -mdebugger -Wcast-align -fno-short-double -ftoplevel-reorder -IC:\DOCUME~1\user\LOCALS~1\Temp\build6103797664663581553.tmp -mprocessor=32MX795F512L -DF_CPU=80000000L -DARDUINO=10605 -D_BOARD_MEGA_ -DMPIDEVER=16777998 -DMPIDE=150 -DIDE=Arduino -MMD -IC:\Program Files\Arduino\hardware\chipkit-core\pic32\cores\pic32 -IC:\Program Files\Arduino\hardware\chipkit-core\pic32\variants\Max32 -IC:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master C:\DOCUME~1\user\LOCALS~1\Temp\build6103797664663581553.tmp\sketch_nov11a_test.cpp -o C:\DOCUME~1\user\LOCALS~1\Temp\build6103797664663581553.tmp\sketch_nov11a_test.cpp.o
In file included from sketch_nov11a_test.ino:1:0:
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h: In function 'void i2c_wait_scl_high()':
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:208:23: error: 'SCL_PORT' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:208:23: error: '_SFR_IO_ADDR' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:208:46: error: 'SCL_PIN' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h: In function 'boolean i2c_init()':
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:262:23: error: 'SCL_PORT' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:262:23: error: '_SFR_IO_ADDR' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:262:47: error: 'SCL_PIN' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:264:23: error: 'SDA_PORT' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:264:47: error: 'SDA_PIN' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h: In function 'bool i2c_start(uint8_t)':
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:282:25: error: 'SDA_PORT' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:282:25: error: '_SFR_IO_ADDR' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:282:49: error: 'SDA_PIN' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:283:21: error: 'SCL_PORT' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:283:43: error: 'SCL_PIN' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h: In function 'bool i2c_rep_start(uint8_t)':
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:307:25: error: 'SCL_PORT' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:307:25: error: '_SFR_IO_ADDR' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:307:49: error: 'SCL_PIN' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:308:25: error: 'SDA_PORT' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:308:49: error: 'SDA_PIN' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h: In function 'void i2c_start_wait(uint8_t)':
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:335:24: error: 'SDA_PORT' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:335:24: error: '_SFR_IO_ADDR' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:335:48: error: 'SDA_PIN' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:336:20: error: 'SCL_PORT' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:336:42: error: 'SCL_PIN' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h: In function 'void i2c_stop()':
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:355:25: error: 'SCL_PORT' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:355:25: error: '_SFR_IO_ADDR' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:355:49: error: 'SCL_PIN' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:356:25: error: 'SDA_PORT' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:356:49: error: 'SDA_PIN' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h: In function 'bool i2c_write(uint8_t)':
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:431:22: error: 'SCL_PORT' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:431:22: error: '_SFR_IO_ADDR' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:431:46: error: 'SCL_PIN' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:432:22: error: 'SDA_PORT' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:432:46: error: 'SDA_PIN' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h: In function 'uint8_t i2c_read(bool)':
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:500:22: error: 'SCL_PORT' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:500:22: error: '_SFR_IO_ADDR' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:500:46: error: 'SCL_PIN' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:501:22: error: 'SDA_PORT' was not declared in this scope
C:\Documents and Settings\user\My Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:501:46: error: 'SDA_PIN' was not declared in this scope
Error compiling.
Thanks in advance for the help!
Mon, 18 Jan 2016 22:19:50 +0000
Hi ahurley,
I just found your post while looking for unanswered posts relating to Digilent's hardware. I'm sorry you never received an answer, but I'll pick up this thread in case you or anybody else is still having this problem.
Hope this helps!
Tommy
Thu, 30 Jun 2016 15:57:18 +0000
Hello,
I am putting together a code using the SoftI2CMaster library for a sensor also. In the sensor's datasheet, it is stated that a repeated state is needed, that's why I went with this library.
At first I got the same compile error ahurley mentioned, and putting the #define's first fixed this, but I was wondering if you then got the following error and how you fixed it if you were able to. Tommy, if you have used this library and have any suggestions, it would appreciated!
Here are all the errors I got:
Arduino: 1.6.9 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"
libraries\MCDC_soft_i2c\MCDC_soft_i2c.cpp.o: In function `ass_i2c_delay_half':
C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: multiple definition of `ass_i2c_delay_half'
sketch\MCDC04TEST.ino.cpp.o:C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: first defined here
c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions
libraries\MCDC_soft_i2c\MCDC_soft_i2c.cpp.o: In function `ass_i2c_delay_half':
C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: multiple definition of `ass_i2c_wait_scl_high'
sketch\MCDC04TEST.ino.cpp.o:C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: first defined here
libraries\MCDC_soft_i2c\MCDC_soft_i2c.cpp.o: In function `ass_i2c_delay_half':
C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: multiple definition of `i2c_init()'
sketch\MCDC04TEST.ino.cpp.o:C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: first defined here
libraries\MCDC_soft_i2c\MCDC_soft_i2c.cpp.o: In function `ass_i2c_delay_half':
C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: multiple definition of `i2c_start(unsigned char)'
sketch\MCDC04TEST.ino.cpp.o:C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: first defined here
libraries\MCDC_soft_i2c\MCDC_soft_i2c.cpp.o: In function `ass_i2c_delay_half':
C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: multiple definition of `ass_i2c_write'
sketch\MCDC04TEST.ino.cpp.o:C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: first defined here
libraries\MCDC_soft_i2c\MCDC_soft_i2c.cpp.o: In function `ass_i2c_delay_half':
C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: multiple definition of `i2c_rep_start(unsigned char)'
sketch\MCDC04TEST.ino.cpp.o:C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: first defined here
libraries\MCDC_soft_i2c\MCDC_soft_i2c.cpp.o: In function `ass_i2c_delay_half':
C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: multiple definition of `i2c_start_wait(unsigned char)'
sketch\MCDC04TEST.ino.cpp.o:C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: first defined here
libraries\MCDC_soft_i2c\MCDC_soft_i2c.cpp.o: In function `ass_i2c_delay_half':
C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: multiple definition of `ass_i2c_stop'
sketch\MCDC04TEST.ino.cpp.o:C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: first defined here
libraries\MCDC_soft_i2c\MCDC_soft_i2c.cpp.o: In function `ass_i2c_delay_half':
C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: multiple definition of `i2c_read(bool)'
sketch\MCDC04TEST.ino.cpp.o:C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Thu, 30 Jun 2016 16:01:38 +0000
Hello,
I am using the SoftI2CMaster library to work with a sensor also. I went with this library because in the sensor's datasheet, it said a repeated start condition is needed.
I am currently getting a compile error with the code and wanted to know if either of you encountered the same error. Any suggestions would be greatly appreciated!
Error:
Arduino: 1.6.9 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"
libraries\MCDC_soft_i2c\MCDC_soft_i2c.cpp.o: In function `ass_i2c_delay_half':
C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: multiple definition of `ass_i2c_delay_half'
sketch\MCDC04TEST.ino.cpp.o:C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: first defined here
c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions
libraries\MCDC_soft_i2c\MCDC_soft_i2c.cpp.o: In function `ass_i2c_delay_half':
C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: multiple definition of `ass_i2c_wait_scl_high'
sketch\MCDC04TEST.ino.cpp.o:C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: first defined here
libraries\MCDC_soft_i2c\MCDC_soft_i2c.cpp.o: In function `ass_i2c_delay_half':
C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: multiple definition of `i2c_init()'
sketch\MCDC04TEST.ino.cpp.o:C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: first defined here
libraries\MCDC_soft_i2c\MCDC_soft_i2c.cpp.o: In function `ass_i2c_delay_half':
C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: multiple definition of `i2c_start(unsigned char)'
sketch\MCDC04TEST.ino.cpp.o:C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: first defined here
libraries\MCDC_soft_i2c\MCDC_soft_i2c.cpp.o: In function `ass_i2c_delay_half':
C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: multiple definition of `ass_i2c_write'
sketch\MCDC04TEST.ino.cpp.o:C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: first defined here
libraries\MCDC_soft_i2c\MCDC_soft_i2c.cpp.o: In function `ass_i2c_delay_half':
C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: multiple definition of `i2c_rep_start(unsigned char)'
sketch\MCDC04TEST.ino.cpp.o:C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: first defined here
libraries\MCDC_soft_i2c\MCDC_soft_i2c.cpp.o: In function `ass_i2c_delay_half':
C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: multiple definition of `i2c_start_wait(unsigned char)'
sketch\MCDC04TEST.ino.cpp.o:C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: first defined here
libraries\MCDC_soft_i2c\MCDC_soft_i2c.cpp.o: In function `ass_i2c_delay_half':
C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: multiple definition of `ass_i2c_stop'
sketch\MCDC04TEST.ino.cpp.o:C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: first defined here
libraries\MCDC_soft_i2c\MCDC_soft_i2c.cpp.o: In function `ass_i2c_delay_half':
C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: multiple definition of `i2c_read(bool)'
sketch\MCDC04TEST.ino.cpp.o:C:\Users\dawson1\Documents\Arduino\libraries\SoftI2CMaster-master/SoftI2CMaster.h:206: first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Fri, 01 Jul 2016 09:56:39 +0000
c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/bin/ld.exe
That's the Arduino compiler, not the chipKIT compiler. Are you sure you're compiling for a chipKIT board?
Also, if this (https://github.com/todbot/SoftI2CMaster/blob/master/SoftI2CMaster.cpp) is the library you are using, it's for Arduino boards only, not chipKIT boards.
If you need repeated-start on chipKIT boards the Wire library (and the DTWI library) of chipKIT core both fully support repeated start. For the Wire library (simplest to use) you just provide a boolean parameter to .endTransmission():
Wire.endTransmission(); // Send a stop bit
... or ...
Wire.endTransmission(false); // Don't send a stop bit (repeated start)
I use that to communicate with a light level sensor that requires repeated start:
Wire.beginTransmission(0x29);
Wire.write(0x88);
Wire.endTransmission(false);
Wire.requestFrom(0x29, 4);
uint16_t ch1 = Wire.read();
ch1 |= (Wire.read() << 8);
uint16_t ch0 = Wire.read();
ch0 |= (Wire.read() << 8);
First you send a write to select the register to read from (0x88) and then with a repeated start you send a read request for 4 bytes to read the contents of that and the three successive registers.