New to Teensy and looking for some guidance with compiling errors. Graphicstest???

Not open for further replies.


I just got my first Teensy (3.1) and TFT display.

I am running Arduino version 1.06 and Teensyduino version 1.23

I attempted to run the graphics test ( ) and am getting all kinds of compiling errors:

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/wiring.h:33:0,
from C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/WProgram.h:15,
from C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/Arduino.h:1,
from C:\Users\use\Documents\Arduino\libraries\SPI\SPI.h:15,
from C:\Users\use\Documents\Arduino\libraries\SPI\SPI.cpp:12:
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/core_pins.h: In function 'void digitalWriteFast(uint8_t, uint8_t)':
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/core_pins.h:887:24: error: 'portSetRegister' was not declared in this scope
*portSetRegister(pin) = digitalPinToBitMask(pin);
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/core_pins.h:887:51: error: 'digitalPinToBitMask' was not declared in this scope
*portSetRegister(pin) = digitalPinToBitMask(pin);
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/core_pins.h:889:26: error: 'portClearRegister' was not declared in this scope
*portClearRegister(pin) = digitalPinToBitMask(pin);
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/core_pins.h:889:53: error: 'digitalPinToBitMask' was not declared in this scope
*portClearRegister(pin) = digitalPinToBitMask(pin);
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/core_pins.h: In function 'uint8_t digitalReadFast(uint8_t)':
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3/core_pins.h:976:32: error: 'portInputRegister' was not declared in this scope
return *portInputRegister(pin);

Any assistance would be appreciated.
Initially I thought maybe you didn't have Teensy 3.1 selected under 'Tools->Board' but I changed my mind and have decided that the only suggestion I can think of with confidence is to try starting again with Arduino version > 1.6.2

By memory the only one time I tried 1.0.6 it was as buggy as hell and I used 1.0.5-r2 till 1.6.2 came out, made the mistake of trying 1.6.2 and it seemed rubbish as well - but, I only have nice things to say about 1.6.3, well, to anybody sticking with Arduino (or just beginning really)

I'm finding I quite like uECIDE better (so far) but become happy with an Arduino/Teensyduino install before looking at that if you are just beginning.
I have no idea how you could be getting that error. It's almost like your copy of Arduino+Teensyduino is somehow corrupted. You obviously have parts of the core library like core_pins.h, but you're missing stuff that's supposed to come from pins_arduino.h in the same directory!

Probably the best advise I can give it to completely uninstall Arduino. Make sure C:\Program Files (x86)\Arduino is completely deleted. Then reinstall a fresh copy of Arduino 1.0.6 (or better, 1.6.4) and reinstall Teensyduino.

Be on the lookout for anything going wrong or unexpected during the reinstall. This is a very mysterious set of errors that really should never happen. I have no idea how an install could get corrupted like this.... and I'd really like to know, so if you see anything go wrong, please take note and post a followup here. That sort of info really helps me to help others in the future.
Oh, looking this over again, I noticed this!!!

from C:\Users\use\Documents\Arduino\libraries\SPI\SPI.h:15,
from C:\Users\use\Documents\Arduino\libraries\SPI\SPI.cpp:12:

That sure looks like a copy of the SPI library, but not the one Teensyduino installed. It's a copy in your Documents/Arduino folder, which is overriding the ones from Arduino and Teensyduino.

Arduino is designed so you can override any library. But it's a "too powerful" feature in many cases, because those copies don't update. Sometimes an old version works for months or years, but then when other libraries or code updates, it causes all sorts of mysterious errors.

Newer versions of Arduino have a patch I wrote, which prints a nice warning message when you have 2 or more copies of the same library and Arduino has to pick one. But it never got back-ported to Arduino 1.0.6. If you try with 1.6.4, you'll probably get a message explaining the problem. Maybe you already have?
Thanks for clearing that up Paul.

Do you actually recommend using 1.6.4? instead of 1.0.6?

I try to keep several versions loaded in case something does not work....

I guess that bit me here.
Usually the latest versions are the best.

But if you have a specific library designed only for the old versions, then you'd need to use 1.0.6. Generally, I'd suggest to do with the latest, unless you run into a specific problem that requires going back to an older versions.
I have encountered a related problem. I just upgraded from 1.0.6 to 1.6.4. I am currently working with an Adafruit 320x480 3.5" TFT screen module. It works fine with both the graphicstest and spitftbitmap files. I just installed Teensyduino. When I try to compile for the Teensy I get this error message:
Arduino: 1.6.4 (Windows 7), TD: 1.23, Board: "Teensy 3.1, Serial, 96 MHz optimized (overclock), US English"

Build options changed, rebuilding all

Using library SPI in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI (1.0.x format)

Using library Adafruit-GFX-Library-master in folder: C:\Users\sypniewski\Documents\Arduino\libraries\Adafruit-GFX-Library-master (1.0.x format)

Using library Adafruit_HX8357_Library-master in folder: C:\Users\sypniewski\Documents\Arduino\libraries\Adafruit_HX8357_Library-master (1.0.x format)

C:\Program Files (x86)\Arduino/hardware/tools/arm/bin/arm-none-eabi-g++ -c -O -g -Wall -ffunction-sections -fdata-sections -MMD -nostdlib -fno-exceptions -felide-constructors -std=gnu++0x -fno-rtti -mthumb -mcpu=cortex-m4 -D__MK20DX256__ -DTEENSYDUINO=123 -DARDUINO=10604 -DF_CPU=96000000 -DARDUINO_ARCH_AVR -DUSB_SERIAL -DLAYOUT_US_ENGLISH -IC:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3 -IC:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI -IC:\Users\sypniewski\Documents\Arduino\libraries\Adafruit-GFX-Library-master -IC:\Users\sypniewski\Documents\Arduino\libraries\Adafruit_HX8357_Library-master C:\Users\SYPNIE~1\AppData\Local\Temp\build4365309737841510996.tmp\graphicstest.cpp -o C:\Users\SYPNIE~1\AppData\Local\Temp\build4365309737841510996.tmp\graphicstest.cpp.o

In file included from graphicstest.ino:18:0:
C:\Users\sypniewski\Documents\Arduino\libraries\Adafruit_HX8357_Library-master/Adafruit_HX8357.h:163:14: error: 'RwReg' does not name a type
volatile RwReg *mosiport, *clkport, *dcport, *rsport, *csport;
Error compiling.
I do not get this error when compiling for the UNO. I've selected the Teensy 3.1 with the proper COM port so that's not the problem. Any help or suggestions would be appreciated.
I receive the same error message.
Fresh Install, tested with Teensyduino 1.23 on Arduino IDE 1.6.3 and 1.6.4.
Any help would be appreciated.

Problematic is this code in Adafruit_HX8357.h:
#if defined (__AVR__)
  uint8_t mySPCR;
  volatile uint8_t *mosiport, *clkport, *dcport, *rsport, *csport;
  int8_t  _cs, _dc, _rst, _mosi, _miso, _sclk;
  uint8_t  mosipinmask, clkpinmask, cspinmask, dcpinmask;
[COLOR="#FF0000"]#elif defined (__arm__)
    volatile RwReg *mosiport, *clkport, *dcport, *rsport, *csport;
    uint32_t  _cs, _dc, _rst, _mosi, _miso, _sclk;
    uint32_t  mosipinmask, clkpinmask, cspinmask, dcpinmask;[/COLOR]

TIA Peter
Last edited:
schmelle2: Have you tried running this with ARDUINO 1.0.6? I've been meaning to but I haven't yet. Maybe next week. I've encountered some problems moving from 1.0.6 to 1.6.4.
Hi bps,
unfortunately it's not working with 1.0.6 too.

BR Peter

BTW: I'll try now Arduino IDE 1.6.5-r2 and TeensyDuino 1.2.4-Beta3
I dont have this library (Adafruit_HX8357) but looking at the compileroutput there seems to be an extra blank
in the include path directive:

-IC:\Users\sypniewski\Documents\Arduino\libraries\A dafruit_HX8357_Library-master
Last edited:
I got same messages trying to compile the example "breakouttouchpaint" from "Adafruit_HX8357_Library-master"

Build options changed, rebuilding all
Using library Adafruit GFX Library in folder: /Applications/ 
Using library SPI in folder: /Applications/ (1.0.x format)
Using library Adafruit_HX8357_Library-master in folder: /Volumes/Macintosh HD/Users/jblaze/Documents/Arduino/libraries/Adafruit_HX8357_Library-master (1.0.x format)
Using library TouchScreen_Due in folder: /Volumes/Macintosh HD/Users/jblaze/Documents/Arduino/libraries/TouchScreen_Due (1.0.x format)

/Applications/ -c -O -g -Wall -ffunction-sections -fdata-sections -MMD -nostdlib -fno-exceptions -felide-constructors -std=gnu++0x -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=125 -DARDUINO=10605 -DF_CPU=96000000 -DARDUINO_ARCH_AVR -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I/Applications/ -I/Applications/ -I/Applications/ -I/Volumes/Macintosh HD/Users/jblaze/Documents/Arduino/libraries/Adafruit_HX8357_Library-master -I/Volumes/Macintosh HD/Users/jblaze/Documents/Arduino/libraries/TouchScreen_Due /var/folders/qr/4tmjsng929vds8t6j7mkl6700000gn/T/build8624010319733827930.tmp/breakouttouchpaint.cpp -o /var/folders/qr/4tmjsng929vds8t6j7mkl6700000gn/T/build8624010319733827930.tmp/breakouttouchpaint.cpp.o 
In file included from /Applications/,
from /Applications/,
from /Applications/,
from /Applications/,
from breakouttouchpaint.ino:19:
/Applications/ In function 'void digitalWriteFast(uint8_t, uint8_t)':
/Applications/ error: 'portSetRegister' was not declared in this scope
*portSetRegister(pin) = digitalPinToBitMask(pin);
/Applications/ error: 'digitalPinToBitMask' was not declared in this scope
*portSetRegister(pin) = digitalPinToBitMask(pin);
/Applications/ error: 'portClearRegister' was not declared in this scope
*portClearRegister(pin) = digitalPinToBitMask(pin);
/Applications/ error: 'digitalPinToBitMask' was not declared in this scope
*portClearRegister(pin) = digitalPinToBitMask(pin);
/Applications/ In function 'uint8_t digitalReadFast(uint8_t)':
/Applications/ error: 'portInputRegister' was not declared in this scope
return *portInputRegister(pin);
Error compiling.

I'm using Teensiduino 1.25-beta2 (Mac OSX) with Arduino 1.6.5

Can anyone help? Seems like it does not use the correct "pins_ardiono.h". I installed Arduino and Teensyduino again, but no changes. I tried to '#include "/Applications/"' but it does not help.

Does anyone has an idea?
Last edited:
Update: I was able to break this down to "pins_arduino.h". It does neither detect "#if defined(KINETISK)" nor "#elif defined(KINETISL)"

Which one should I go for?
I don't have the TouchScreen_Due library and can't find a download link with google. I've downloaded the Touch-Screen-Library from Adafruit: and can see the same error output.

I've modified the TouchScreen.cpp:

// Touch screen library with X Y and Z (pressure) readings as well
// as oversampling to avoid 'bouncing'
// (c) ladyada / adafruit
// Code under MIT License

#if defined(__MKL26Z64__) || defined(__MK20DX128__) || defined(__MK20DX256__) // TEENSY LC/3.0/3.1/3.2
  #include "Arduino.h"
  #include "pins_arduino.h"
  #include "wiring_private.h"
  #ifdef __AVR__
    #include <avr/pgmspace.h>
  #elif defined(ESP8266)
    #include <pgmspace.h>

#include "TouchScreen.h"

// increase or decrease the touchscreen oversampling. This is a little different than you make think:
// 1 is no oversampling, whatever data we get is immediately returned
// 2 is double-sampling and we only return valid data if both points are the same
// 3+ uses insert sort to get the median value.
// We found 2 is precise yet not too slow so we suggest sticking with it!

Now the breakouttouchpaint example compiles without errors.
You're using 4 libraries. I have only 2 of them, SPI and Adafruit_GFX. I can't attempt to reproduce the problem without complete code.

You can provide links to the exact code you're using for the other two?

The name "Touchscreen_Due" would seem to suggest a library written only for Arduino Due. Perhaps it can not work on Teensy?
I got it working finally.
I hope this will help somebody. Here is what I used.
I have and adafruit 320 x 480 3.5 inch tft product code 2050 with the HX8357D chip.
With a Teensy 3.2 in SPI mode.
I have Arduino 1.6.6, teensyduino 1.26.
I used the standard adafruit touch library
But added HWGUYS code from here

The code I used is the teensy's breakouttouchpaint but for the ILI9341 tft.
The ILI9341 library works on the HX8357D but the HX8357 library does not.

I hope this saves somebody a weeks worth of searching.

Not open for further replies.