I've see other folks in this forum having similar problems.
The display is NHD-2.8-25664UCY2.
The MOSI (pin 7) and SCK (pin 14) pins are being used by the SD card and serial flash memory.
Yet, I can only make the display work using the standard SPI pins MOSI (pin 11), SCK (pin 13), -CS (pin 10) and RS (pin 9).
This will certainly interfere with the audio board which uses pins 11 & 13 for I2S communication with the codec.
Code is posted below and attached .ino file
Thanks in advance to anyone who has some insight into this situation.
/*
This is eventually going to be an audio project. An audio tester of sorts
that generates test signals and displays the response. A little audio
spectrum analyzer. The audio portion, FFTs and all, are working ok. Actually,
the project will work running the display with software SPI. It's just that
the screen updates take about 450ms. I need a faster rate.
I'm trying to get the Teensy 3.1 to run an NHD-2.8-25664UCY2 OLED display
using the alternative hardware SPI pins. I see from the schematic that the
standard SPI pins are used by the audio codec chip for I2S. My project will
not be using the SD card or serial flash memory. So, I thought it would be
OK to 'borrow' pin 10 for the display's -CS line. It works using pin 10.
Using the same logic, it seems OK to 'borrow' pin 6. But that doesn't work.
I see no activity on the -CS line on my oscilloscope in that condition.
Similarly, I can't move the register select line(rs), either. I using pin 9.
If I try pin 8, it doesn't work. So, I seem to be stuck using the standard pins:
rs = pin 9
cs = pin 10
sd = pin 11
sck = pin 13
The code below works.
If I re-wire and include the SPI.setMOSI(7) and SPI.setSCK(14) commands, the
display remains blank and no activity on the SCK line.
I hope you can shed some light on this situation. I love the Teensy board,
by the way, and the audio board. And I'm kinda stuck on this display for now.
*/
//
#include "U8glib.h"
#include <u8g_teensy.h>
#include <SPI.h>
#include <Audio.h>
#include <Wire.h>
#include <SD.h>
#include <SerialFlash.h>
//
int rst = 2; // reset pin - your choice
int rs = 9; // register select pin - your choice
int cs = 10; // SPI ss
int sd = 7; // SPI mosi
int sck = 14; // SPI sck
int test = 16;
byte k = 0; // loop counter
// constuctor for u8glib - software SPI
// U8GLIB_NHD31OLED_2X_BW u8g(sck, sd, cs, rs, rst);
// constuctor for u8glib - hardware SPI
U8GLIB display(&u8g_dev_ssd1322_nhd31oled_2x_bw_hw_spi, u8g_com_hw_spi_fn);
U8GLIB_NHD31OLED_2X_BW u8g(cs, rs, rst);
//
// ***********************************************************************
void setup(void) {
Serial.begin(9600);
// select font
u8g.setFont(u8g_font_unifont);
// flip screen, if required
u8g.setRot180();
// set SPI backup if required
//u8g.setHardwareBackup(u8g_backup_avr_spi);
// 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);
}
pinMode(rst,OUTPUT);
pinMode(rs,OUTPUT);
pinMode(cs,OUTPUT);
pinMode(sck,OUTPUT);
pinMode(sd,OUTPUT);
pinMode(test,OUTPUT);
//
digitalWrite(rst,HIGH);
digitalWrite(rs,HIGH);
digitalWrite(cs,HIGH);
digitalWrite(sck,HIGH);
digitalWrite(sd,HIGH);
digitalWrite(test,HIGH);
//
// reset the display
digitalWrite(rst,LOW);
delay(10);
digitalWrite(rst,HIGH);
//
// empty loop to clear the screen
u8g.firstPage();
do {
} while( u8g.nextPage() );
//
//SPI.setMOSI(7);
//SPI.setSCK(14);
//
}
//
// ***********************************************************************
void loop(void) {
digitalWrite(test,HIGH);
delay(1);
digitalWrite(test,LOW);
// picture loop
k = k -1;
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
}
// ***********************************************************************
void draw(void) {
u8g.drawStr(255 -k, 35, "Hello World!");
}
// ***********************************************************************
The display is NHD-2.8-25664UCY2.
The MOSI (pin 7) and SCK (pin 14) pins are being used by the SD card and serial flash memory.
Yet, I can only make the display work using the standard SPI pins MOSI (pin 11), SCK (pin 13), -CS (pin 10) and RS (pin 9).
This will certainly interfere with the audio board which uses pins 11 & 13 for I2S communication with the codec.
Code is posted below and attached .ino file
Thanks in advance to anyone who has some insight into this situation.
/*
This is eventually going to be an audio project. An audio tester of sorts
that generates test signals and displays the response. A little audio
spectrum analyzer. The audio portion, FFTs and all, are working ok. Actually,
the project will work running the display with software SPI. It's just that
the screen updates take about 450ms. I need a faster rate.
I'm trying to get the Teensy 3.1 to run an NHD-2.8-25664UCY2 OLED display
using the alternative hardware SPI pins. I see from the schematic that the
standard SPI pins are used by the audio codec chip for I2S. My project will
not be using the SD card or serial flash memory. So, I thought it would be
OK to 'borrow' pin 10 for the display's -CS line. It works using pin 10.
Using the same logic, it seems OK to 'borrow' pin 6. But that doesn't work.
I see no activity on the -CS line on my oscilloscope in that condition.
Similarly, I can't move the register select line(rs), either. I using pin 9.
If I try pin 8, it doesn't work. So, I seem to be stuck using the standard pins:
rs = pin 9
cs = pin 10
sd = pin 11
sck = pin 13
The code below works.
If I re-wire and include the SPI.setMOSI(7) and SPI.setSCK(14) commands, the
display remains blank and no activity on the SCK line.
I hope you can shed some light on this situation. I love the Teensy board,
by the way, and the audio board. And I'm kinda stuck on this display for now.
*/
//
#include "U8glib.h"
#include <u8g_teensy.h>
#include <SPI.h>
#include <Audio.h>
#include <Wire.h>
#include <SD.h>
#include <SerialFlash.h>
//
int rst = 2; // reset pin - your choice
int rs = 9; // register select pin - your choice
int cs = 10; // SPI ss
int sd = 7; // SPI mosi
int sck = 14; // SPI sck
int test = 16;
byte k = 0; // loop counter
// constuctor for u8glib - software SPI
// U8GLIB_NHD31OLED_2X_BW u8g(sck, sd, cs, rs, rst);
// constuctor for u8glib - hardware SPI
U8GLIB display(&u8g_dev_ssd1322_nhd31oled_2x_bw_hw_spi, u8g_com_hw_spi_fn);
U8GLIB_NHD31OLED_2X_BW u8g(cs, rs, rst);
//
// ***********************************************************************
void setup(void) {
Serial.begin(9600);
// select font
u8g.setFont(u8g_font_unifont);
// flip screen, if required
u8g.setRot180();
// set SPI backup if required
//u8g.setHardwareBackup(u8g_backup_avr_spi);
// 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);
}
pinMode(rst,OUTPUT);
pinMode(rs,OUTPUT);
pinMode(cs,OUTPUT);
pinMode(sck,OUTPUT);
pinMode(sd,OUTPUT);
pinMode(test,OUTPUT);
//
digitalWrite(rst,HIGH);
digitalWrite(rs,HIGH);
digitalWrite(cs,HIGH);
digitalWrite(sck,HIGH);
digitalWrite(sd,HIGH);
digitalWrite(test,HIGH);
//
// reset the display
digitalWrite(rst,LOW);
delay(10);
digitalWrite(rst,HIGH);
//
// empty loop to clear the screen
u8g.firstPage();
do {
} while( u8g.nextPage() );
//
//SPI.setMOSI(7);
//SPI.setSCK(14);
//
}
//
// ***********************************************************************
void loop(void) {
digitalWrite(test,HIGH);
delay(1);
digitalWrite(test,LOW);
// picture loop
k = k -1;
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
}
// ***********************************************************************
void draw(void) {
u8g.drawStr(255 -k, 35, "Hello World!");
}
// ***********************************************************************