teensy 3.0 with teensyduino and u8glib

Hi all,

I have a problem that is hard for me to track down and I also posted in the pjrc forum, but to no avail so far. I have no experience with arduino (just "plain" C and C++ programming for AVRs) or the ARM used on the teensy 3.0. To sum it up, I'm lost. This is my setup:

arduino 1.0.5 teensyduino 1.16 http://www.pjrc.com/teensy/teensyduino.html u8glib_arduino_v1.13 http://code.google.com/p/u8glib/downloads/detail?name=u8glib_arduino_v1.13.zip ubuntu 12.04 teensy 3.0 http://www.pjrc.com/teensy/index.html

The display I want to use is the adafruit ssd1351 128x128 oled display ([urlhttp://www.adafruit.com/products/1431][/url]), which worked flawlessly with the teensy2.0 (atmega32u4) and u8glib. It's not yet connected, because I cannot compile the u8glib hello world example (included in u8glib_arduino):

#include "U8glib.h"

U8GLIB_SSD1351_128X128_332 u8g(13, 11, 10, 9, 8); // Teensy 3.0: SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RESET = 8 (http://electronics.ilsoft.co.uk/ArduinoShield.aspx)

void draw(void) {
  // graphic commands to redraw the complete screen should be placed here  
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr( 0, 22, "Hello World!");
}

void setup(void) {
  pinMode(8, OUTPUT);
  // assign default color value
  if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
    u8g.setColorIndex(255);     // white
  }
  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
    u8g.setColorIndex(3);         // max intensity
  }
  else if ( u8g.getMode() == U8G_MODE_BW ) {
    u8g.setColorIndex(1);         // pixel on
  }
  else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
    u8g.setHiColorByRGB(255,255,255);
  }
}

void loop(void) {
  // picture loop
  u8g.firstPage();  
  do {
    draw();
  } while( u8g.nextPage() );
  
  // rebuild the picture after some delay
  delay(500);
}

These are the errors I get:

~/builds/arduino/arduino-1.0.5/libraries/U8glib/utility/u8g_com_arduino_sw_spi.c: In function 'u8g_digital_write_sam_high':
~/builds/arduino/arduino-1.0.5/libraries/U8glib/utility/u8g_com_arduino_sw_spi.c:170:14: error: 'g_APinDescription' undeclared (first use in this function)

~/builds/arduino/arduino-1.0.5/libraries/U8glib/utility/u8g_com_arduino_sw_spi.c: In function 'u8g_digital_write_sam_low':
~/builds/arduino/arduino-1.0.5/libraries/U8glib/utility/u8g_com_arduino_sw_spi.c:175:16: error: 'g_APinDescription' undeclared (first use in this function)

When I remove this source file from the library folder (I dont want to use the software SPI, after all), the next error that occurs is that "sam.h" cannot be found. It seems that something very basic (mcu headers) is missing, but as I don't have any experience with arduino and the teensy I don't know where that header should be or what I could include instead.

Any help is appreciated.

Regards

Christoph

Hi

The Arduino and AVR variants of U8glib make use of low level procedures. I have tested and implemented U8glib for the official Ardiono boards (Uno, Due, Leonardo) and the ChipKit board (PIC32). Unfortunately it does not support the Freescale K20 controllers.

Oliver

Acutally, someone managed to run u8glib on a teensy 3.0, but they had different errors:

http://forum.pjrc.com/threads/23445-Teensy-3-0-and-u8glib

The above thread motivated me to go ahead and try this. I'll see what the pjrc support can come up with, but it has been done.

Regards

Christoph

At least the missing “#include <Arduino.h>” should now be there.
I am sorry for not beeing more helpful here.

Oliver

Well, I'll try to find a fix for this as soon as I can. u8glib should (attempt to) just use the arduino interface (which teensyduino provides), and there has been a working version (the code compiles with u8glib_arduino_v1.12). If I can spot and fix the differences between the two versions, I'll post them here.

Anyone got this to go? Not helping here but would like to use u8glib with my teensy 3.0 and can't get past compilation errors!

Q

As far as i remember, version v1.14 of u8glib includes all fixes known to me. Which version do you use? v1.14? What are the exact errors you get?

Oliver

I am using v1.14, arduino v1.05 / teensyduino

Arduino: 1.0.5 (Mac OS X), Board: "Teensy 3.0" /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c: In function 'u8g_spi_out': /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:302:15: error: invalid type argument of '->' (have 'SPI_t') /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:302:26: error: 'SPI_SR_TDRE' undeclared (first use in this function) /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:302:26: note: each undeclared identifier is reported only once for each function it appears in /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:305:7: error: invalid type argument of '->' (have 'SPI_t') /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c: In function 'u8g_com_arduino_hw_spi_fn': /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:324:7: error: 'REG_PMC_PCER0' undeclared (first use in this function) /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:324:31: error: 'ID_PIOA' undeclared (first use in this function) /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:324:50: error: 'ID_SPI0' undeclared (first use in this function) /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:327:7: error: 'REG_PIOA_PDR' undeclared (first use in this function) /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:330:11: error: invalid type argument of '->' (have 'SPI_t') /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:330:22: error: 'SPI_CR_SPIDIS' undeclared (first use in this function) /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:331:11: error: invalid type argument of '->' (have 'SPI_t') /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:331:22: error: 'SPI_CR_SWRST' undeclared (first use in this function) /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:332:11: error: invalid type argument of '->' (have 'SPI_t') /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:333:11: error: invalid type argument of '->' (have 'SPI_t') /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:333:22: error: 'SPI_CR_SPIEN' undeclared (first use in this function) /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:337:11: error: invalid type argument of '->' (have 'SPI_t') /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:337:22: error: 'SPI_MR_MSTR' undeclared (first use in this function) /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:337:36: error: 'SPI_MR_PCSDEC' undeclared (first use in this function) /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:337:52: error: 'SPI_MR_MODFDIS' undeclared (first use in this function) /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:349:6: error: invalid type argument of '->' (have 'SPI_t') /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:353:6: error: invalid type argument of '->' (have 'SPI_t') /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:357:6: error: invalid type argument of '->' (have 'SPI_t') /Users/quentin/Documents/Arduino/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c:361:6: error: invalid type argument of '->' (have 'SPI_t')

ok, i think the problem is, that you can not use the "Arduino" variant of U8glib, because Teensy 3.0 is an arm controller. Instead: Use "u8glib_arm_v1.14.zip" Provide your own communication callback procedures for Teensy 3.0. See this page as an example: http://blog.bastelhalde.de/?p=759

Oliver

Oliver, I'm curious why seperate libraries? Why can't the code compile time detect the processor, board, & environment and just "make it work"?

--- bill

Hi Bill

Good question.
First, my previous suggestion to use the arm variant for the Teensy is not that good, because the arm variant of u8glib does not contain the C++ interface.

And this is already the main difference between the Arduino and ARM variant: The Arduino code has the C++ interface, the ARM variant only has the C interface. Additionally the ARM variant is more generic than the Arduino variant. The base part of the library does not contain any micro-controller specific code. Infact the arm variant of u8glib should be renamed to “u8glib_generic”.

Why can’t the code compile time detect the processor, board, & environment and just “make it work”?

Processor detection is already inside the code.

u8glib arm variant: C++ is missing but clear instructions for porting to new environments are there
u8glib Arduino variant: C++ interface included, but porting is more complicated and not described very well

… i probably need a teensy 3.0 in my hands…

Oliver