Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
5 years, 9 months ago.
How can i solve these errors when reprogramming a MAXREFDES100?
I have tried to program MAXREFDES100# but I've encountered some errors when trying to compile the code. The main code looks like this
//
- include "mbed.h"
- include "MAX14720.h"
- include "MAX30205.h"
Define all I2C addresses
- define MAX30205_I2C_SLAVE_ADDR_TOP (0x92)
- define MAX30205_I2C_SLAVE_ADDR_BOTTOM (0x90)
- define I2C_ADDR_PMIC (0x54)
I2C Masters I2C i2c1(I2C1_SDA, I2C1_SCL); used by MAX30205 (1), MAX30205 (2), BMP280 I2C i2c2(I2C2_SDA, I2C2_SCL); used by MAX14720, MAX30101, LIS2DH
Top Local Temperature Sensor MAX30205 MAX30205_top(&i2c1, MAX30205_I2C_SLAVE_ADDR_TOP); Bottom Local Temperature Sensor MAX30205 MAX30205_bottom(&i2c1, MAX30205_I2C_SLAVE_ADDR_BOTTOM);
PMIC MAX14720 max14720(&i2c2,I2C_ADDR_PMIC);
DigitalOut led(LED1);
Serial Serial pc(USBTX, USBRX);
int main() { max14720.boostEn = MAX14720::BOOST_ENABLED; max14720.init();
led = 0;
Temperature Variables uint16_t rawTemp_top, rawTemp_bottom; float celsius_top, celsius_bottom;
Endless loop
while(1) { Read temperature MAX30205_top.readTemperature(&rawTemp_top); MAX30205_bottom.readTemperature(&rawTemp_bottom);
Convert to Celsius celsius_top = MAX30205_top.toCelsius(rawTemp_top); celsius_bottom = MAX30205_bottom.toCelsius(rawTemp_bottom);
Print Celsius Values pc.printf("Top Temperature: %.2f\370C\n\rBottom Temperature: %.2f\370C \n\n\r", celsius_top, celsius_bottom);
Wait 1 second wait(1); } }
And I use the libraries MAX30205 and MAX14720 from the following links https://os.mbed.com/teams/MaximIntegrated/code/MAX30205/ https://os.mbed.com/components/MAX14720/
The errors are the following
Error: No instance of constructor "MAX30205::MAX30205" matches the argument list in "main.cpp", Line: 15, Col: 24 Error: No instance of constructor "MAX30205::MAX30205" matches the argument list in "main.cpp", Line: 17, Col: 27 Error: Initial value of reference to non-const must be an lvalue in "main.cpp", Line: 42, Col: 39 Error: Initial value of reference to non-const must be an lvalue in "main.cpp", Line: 43, Col: 42
Thank you in advance for your time, with respect, Andrei Sas
1 Answer
5 years, 9 months ago.
Hello Andrei,
These errors appear because the functions/constructors you are using do not align with their declared parameters. Try removing the ampersands (&) in the following lines of code where the errors appear:
MAX30205 MAX30205_top(&i2c1, MAX30205_I2C_SLAVE_ADDR_TOP); //Bottom Local Temperature Sensor MAX30205 MAX30205_bottom(&i2c1, MAX30205_I2C_SLAVE_ADDR_BOTTOM); ... ... MAX30205_top.readTemperature(&rawTemp_top); MAX30205_bottom.readTemperature(&rawTemp_bottom);
The code should be able to compile then. If you were confused on passing by pointer/reference, you can take a look at this article:
https://www.geeksforgeeks.org/passing-by-pointer-vs-passing-by-reference-in-c/
Hope this helps!
-Karen, team Mbed
If this solved your question, please make sure to click the "Thanks" link below!