Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Grand Central M4 bootloader issues
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Grand Central M4 bootloader issues

by tomjennings on Mon Jul 13, 2020 12:57 pm

kaleun96 wrote:Managed to replicate the issue, adding
Code: Select all | TOGGLE FULL SIZE
#include "Wire.h"
to the main.cpp file seems to fix it. Not sure why it's required there...


The Wire.h library needs to be included at the very "top" of your source (before all tabs and libraries that use Wire). This has always been true, but I swear I had sketches that worked without it (even so, it was an error on my part).

I just verified that if I comment out the #include <Wire.h> at the top of an old, reasonably complex sketch, that it compiles without error or warning. I have ALL errors and warnings on. However the I2C bus is not functional.

You'd think that wire.begin() or something would therefore not be defined, and the compiler would complain, but that's not the case. This is a very old issue.

tomjennings
 
Posts: 78
Joined: Thu Aug 17, 2006 1:21 am

Re: Grand Central M4 bootloader issues

by kaleun96 on Mon Jul 13, 2020 1:16 pm

tomjennings wrote: This has always been true, but I swear I had sketches that worked without it.

I have that feeling too. Looking at an old branch of my project I can't find me including it anywhere yet that branch compiled fine at the time and I haven't added any additional I2C hardware and the libraries I'm using are mostly the same.

kaleun96
 
Posts: 17
Joined: Fri Mar 13, 2020 12:55 pm

Re: Grand Central M4 bootloader issues

by tomjennings on Mon Jul 13, 2020 2:06 pm

I will, and you might consider, grepping your entire source tree for "Wire.h". I dimly recall that when I first encountered this well known issue (I for one am perfectly capable of ignoring good and well-known advice for years at a time) that I found one of my libraries loading Wire.h. In that case, that object/device would have it's own Wire library/device and would probably work fine; problems would arise when you add another I2C device...

...I'm guessing here, but if your compilation process put the "second" I2C device after the first, it might see the names and use it and have it work. Rearrange your source and voila! instant convoluted compilation error.

tomjennings
 
Posts: 78
Joined: Thu Aug 17, 2006 1:21 am

Please be positive and constructive with your questions and comments.