Nokia LCD shuts down when using interrupts

I have issues with Nokia 5110 LCD - it shuts down when using interrupts. I decided to use encoder instead of buttons for setting values, but after its first turn LCD becomes blank. I stripped sketch, where I left interrupt function for encoder, which only sets backlight for LCD. I clearly see encoder activity in port monitor, back-light is changing, but screen becomes blank.
The same code works well with buttons instead of encoder.
For display I used Adafruis library, but i changed RST pin into pin 1, because I needed pins 2 and 3.
What is wrong?

By the way, if you “uncomment” Serial.println in the end of loop(), screen also blank. I have doubts the reason is somewhere there.

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
#include <Rotary.h>

Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 1);
Rotary r = Rotary(2, 3);

int light = 90;
int bl=9;
int result = 1;
volatile int enc = 0;

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

  PCICR |= (1 << PCIE2);
  PCMSK2 |= (1 << PCINT18) | (1 << PCINT19);
  sei();

  pinMode(mode, INPUT); //Mode button
  pinMode(bl, OUTPUT); //LCD light

  analogWrite(bl, light);

}// Setup


void loop() {

  display.clearDisplay();

  if (enc == 1) 
  {
    Serial.println(enc);
    if (light<120) light +=30;
    if (light>=120) light = 150;
  }

if (enc == -1) 
 {
      Serial.println(enc);
      if (light >30 ) light -=30;
       if (light<=30) light = 0;
  }
      
analogWrite(bl, light);

display.println(light);
display.display();

//Serial.println(light);
  
} //End loop

ISR(PCINT2_vect) 
      {
      unsigned char result = r.process();
      if (result == DIR_NONE) enc =0;
      else if (result == DIR_CW)  enc =1;
      else if (result == DIR_CCW)  enc =-1;
      }

Ah, the speed of the arduino strikes again!

Read your loop() code yoir clearing the screen every time you go through loop! and your just to slow to see it!

Mark

No, that's not it, I've checked. The same code, but operated by buttons instead of encoder, works well.

Your code from loop

void loop() {

  display.clearDisplay();

  if (enc == 1) 
  {
    Serial.println(enc);
    if (light<120) light +=30;
    if (light>=120) light = 150;
  }

if (enc == -1) 
 {
      Serial.println(enc);
      if (light >30 ) light -=30;
       if (light<=30) light = 0;
  }
      
analogWrite(bl, light);

display.println(light);
display.display();

//Serial.println(light);
  
} //End loop

Your code from loop with only the displays left

void loop() {

  display.clearDisplay();

      
display.println(light);
display.display();

}

Auto format your code and you may see it!

Mark

PS rotary switches should not be used with interrupts

PPS rotary switches need to be debounced

PPPS Saying it works in code you have not posted won’t wash around here

Solved.
The point was Arduino couldn't print to serial and LCD at the same time. I just turned off serial port and it works.