olikraus / u8glib

Arduino Monochrom Graphics Library for LCDs and OLEDs
https://github.com/olikraus/u8glib/wiki
Other
1.24k stars 313 forks source link

ST7920 192x64 HW SPI still use default SPI CS pin #502

Open zbx-sadman opened 4 years ago

zbx-sadman commented 4 years ago

Hello

I use Timer1 PWM on ATMega328P with ST7920 192x64 display (HW SPI mode) and found that any SPI activity cancel PWM generation on D10 (SPI's SS-pin) even it's redirected to other pin.

SW SPI mode works correctly

I think that driver still use default SPI CS pin inside

#include <U8glib.h>

const uint8_t displayCS = 8;

// HW SPI w/ non-default CS - OK
U8GLIB_ST7920_128X64_1X display(13, 11, displayCS);

// HW SPI w/ non-default CS - fail
//U8GLIB_ST7920_128X64_1X display(displayCS);

void setup() {
  Serial.begin(9600);

  display.setFont(u8g_font_profont11);
  display.setRot180();

  // Turn on PWM on Timer #1, channels A & B
  analogWrite(9, 192);
  analogWrite(10, 64);
  Serial.println("Both PWM channels works now");
  delay(5000);
  // Send something to LCD
  display.firstPage();
  do {
    display.drawStr( 0, 20, "I'll broke pin 10");
  } while ( display.nextPage() );
  // That's all, folks!
  Serial.println("Timer #1 channel B dropped");
}

void loop() {}
zbx-sadman commented 4 years ago

U8g2 is works correctly. i'll migrate...