Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AS7265X_Dragonfly.ino build fails #2

Closed
AlecVercruysse opened this issue Oct 9, 2018 · 4 comments
Closed

AS7265X_Dragonfly.ino build fails #2

AlecVercruysse opened this issue Oct 9, 2018 · 4 comments

Comments

@AlecVercruysse
Copy link

I'm having a couple issues with your demo sketch, listed below.

  • Line 38 is: Wire.begin(/*TWI_PINS_20_21*/); // set master mode, which fails compile time since TWI_PINS_20_21 is not defined. Furthermore, the arduino documentation specifies that adding an argument to Wire.begin() will join i2c as slave with the 7 bit address specified, which seems counterintuitive to what this code is doing. I managed to get it working using just 'Wire.begin(), which joins i2c as master.

  • Line 79 is: (delay(100); where it should be delay(100);

  • In your header file, you write:

`#define AS72651_CAL_CHAN0_0 0x14
#define AS72651_CAL_CHAN0_1 0x15
#define AS72651_CAL_CHAN0_2 0x16
#define AS72651_CAL_CHAN0_3 0x17

#define AS72651_CAL_CHAN1_0 0x18
#define AS72651_CAL_CHAN1_1 0x19
#define AS72651_CAL_CHAN1_2 0x1A
#define AS72651_CAL_CHAN1_3 0x1B

#define AS72651_CAL_CHAN2_0 0x1C
#define AS72651_CAL_CHAN2_1 0x1D
#define AS72651_CAL_CHAN2_2 0x1E
#define AS72651_CAL_CHAN2_3 0x1F

#define AS72651_CAL_CHAN3_0 0x20
#define AS72651_CAL_CHAN3_1 0x21
#define AS72651_CAL_CHAN3_2 0x22
#define AS72651_CAL_CHAN3_3 0x23

#define AS72651_CAL_CHAN4_0 0x24
#define AS72651_CAL_CHAN4_1 0x25
#define AS72651_CAL_CHAN4_2 0x26
#define AS72651_CAL_CHAN4_3 0x27

#define AS72651_CAL_CHAN4_0 0x28
#define AS72651_CAL_CHAN4_1 0x29
#define AS72651_CAL_CHAN4_2 0x2A
#define AS72651_CAL_CHAN4_3 0x2B
`
What is the purpose of redefining all of these values multiple times? Won't the final values be the last 4 lines?

  • Finally, for some reason the void loop() function is not entered. I believe it is because the final AS7265X.getStatus() does not return. For example, this code
    Serial.print("attaching interrupt to myIntHandler()..."); attachInterrupt(intPin, myIntHandler, FALLING); Serial.println("done"); Serial.println("status:" + AS7265X.getStatus());
    returns attaching interrupt to myIntHandler()...done and nothing else.

Thanks for the help

@kriswiner
Copy link
Owner

kriswiner commented Oct 9, 2018 via email

@AlecVercruysse
Copy link
Author

I took a second look at the register definitions, and I see how each register is unique except for your last 8 definitions for AS72651_CAL_CHAN4. For example, when I compile, I get these warnings:

sketch/AS7265X.h:57:0: warning: "AS72651_CAL_CHAN4_0" redefined
 #define AS72651_CAL_CHAN4_0         0x28

 ^
sketch/AS7265X.h:52:0: note: this is the location of the previous definition
 #define AS72651_CAL_CHAN4_0         0x24

 ^
sketch/AS7265X.h:58:0: warning: "AS72651_CAL_CHAN4_1" redefined
 #define AS72651_CAL_CHAN4_1         0x29

 ^
sketch/AS7265X.h:53:0: note: this is the location of the previous definition
 #define AS72651_CAL_CHAN4_1         0x25

 ^
sketch/AS7265X.h:59:0: warning: "AS72651_CAL_CHAN4_2" redefined
 #define AS72651_CAL_CHAN4_2         0x2A

 ^
sketch/AS7265X.h:54:0: note: this is the location of the previous definition
 #define AS72651_CAL_CHAN4_2         0x26

 ^
sketch/AS7265X.h:60:0: warning: "AS72651_CAL_CHAN4_3" redefined
 #define AS72651_CAL_CHAN4_3         0x2B

 ^
sketch/AS7265X.h:55:0: note: this is the location of the previous definition
 #define AS72651_CAL_CHAN4_3         0x27

 ^

Since these values are being redefined, what is the purpose of your first 4 definitions for CHAN4?

Furthermore, I'm not quite sure where these definitions are used (and therefore their significance), I couldn't find any usages in anywhere in your repo. Forgive me if I'm missing something, I'm quite inexperienced with C++.

@kriswiner
Copy link
Owner

kriswiner commented Oct 9, 2018 via email

@AlecVercruysse
Copy link
Author

Thanks, got it working. Turns out my other issues were because I forgot to wire up the INT pin... whoops. Also worth noting (if anyone else has issues getting the code to work) I had to change the intPin value from pin 8 to 3 as the arduino mega (and most other arduinos) don't support adding an interrupt on pin 8. Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants