Teensy 4.1 build error in pins_arduino.h

HI,
After many years of using the 3.6 I've now started a project on the 4.1.
I downloaded the latest arduino IDE 2.3.6 and added the link

I'm using VisualGDB and Visual studio 2022.

First build came across this error in pins_arduino.h

#define portOutputRegister(pin) ((digital_pin_to_info_PGM[(pin)].reg + 0))

error: cannot convert 'volatile uint32_t*' {aka 'volatile long unsigned int*'} to 'PortReg*' {aka 'volatile unsigned char*'} in assignment

Can anyone help with this ? My thinking is, this is an out of date version even though I've downloaded the latest ?
 
@teensycoder: You mention Arduino IDE 2.3.6 in your post, but you also mention using VisualGDB and Visual studio 2022. Which are you building with when you encounter the error ?? Does your sketch build OK in Arduino IDE 2.3.6 ??

Mark J Culross
KD5RXT
 
I second what @kd5rxt-mark said, would help to have a better understanding of your build environment.
Like building with IDE or Visual Studio.

Also which version of Teensyduino you installed. I am assuming the most recent non-beta release?

Also source code or example to what did not compile, and maybe additional compiler error messages?
i.e. maybe the issue is not the macro but instead what was passed to it. Or what you are then trying to assign it to.
 
Maybe your build is mistakenly including files from some non-Teensy board(s)?

error: cannot convert 'volatile uint32_t*' {aka 'volatile long unsigned int*'} to 'PortReg*' {aka 'volatile unsigned char*'} in assignment

We don't define a "PortReg" type (or C++ class) anywhere in Teensy's headers or code. The only plausible explanation for this sort of error is accidentally including headers or code from some other place which defines PortReg. Maybe try a slow full text search of all .h files or all code files on your computer for "PortReg". Somewhere, some file must be defining a PortReg type.
 
I'm building with VisualGDB and Visual studion 2022. As I'm sure everyone realises I've had to install the arduino IDE to load the libraries.
The project is not small (16 libraries over 20 CPP file) so moving it into the arduino IDE would take some time.
So, I've loacted the issue, this occurs in the teensy 4.1 build of the same project. The teensy 3.6 is exactly the same project but built for teensy 3.6.

The file causing the problem is for the teensy 4.1
C:\Users\simon\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.59.0\cores\teensy4/pins_arduino.h

the teensy 3.6 build uses
C:\Users\simon\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.59.0\cores\teensy3\pins_arduino.h

The files are different.

The error thrown is
error: cannot convert 'volatile uint32_t*' {aka 'volatile long unsigned int*'} to 'PortReg*' {aka 'volatile unsigned char*'} in assignment
142 | #define portOutputRegister(pin) ((digital_pin_to_info_PGM[(pin)].reg + 0))

The 3.6 version of the definition is
#define portOutputRegister(pin) ((volatile uint8_t *)(digital_pin_to_info_PGM[(pin)].reg + 0))

The origination call is from Adafruit_SH1106-master.

void Adafruit_SH1106::begin(uint8_t vccstate, uint8_t i2caddr, bool reset) {
_vccstate = vccstate;
_i2caddr = i2caddr;

// set pin directions
if (sid != -1){
pinMode(dc, OUTPUT);
pinMode(cs, OUTPUT);
csport = portOutputRegister(digitalPinToPort(cs));
:
:
:
 
So it is failing to build in a private library? That is I consider Adafruit_SH1106-master
is a private library, as no idea when it was downloaded, nor any editing changes that may happened.

With lines like this:
Code:
csport = portOutputRegister(digitalPinToPort(cs));
Look for where csport is defined in that library.

My strong guess is that in the header file there are multiple
#if statements for different board types and I bet there is at least one for the Teensy 3.x.

Could be something like: #ifdef ARDUINO_TEENSY36 but more likely something like:
#if defined(KINETISK)

you would need one for Teensy 4.x and maybe something like: defined(__IMXRT1062__)
And then define the appropriate types...
 
Finally got to the bottom of this. There are two Adafruit_SH1106 libraries. The one in the project is Adafruit_SH1106-master and this causes the problem on the teensy 4.1 build although it's ok for the Teemsy 3.6.
I built a test project with just adding the 'Adafruit_SH1106' library from the list and it loaded the non 'master' version and everything builds.
I can't get rid of the 'master' version from the old project it just won't have it but that's for another forum.

Thanks everyone for your advice.
 
Back
Top