LCD works until I call SPI.begin()

I've set up an LCD1602 module with my Arduino Mega:

#include <SPI.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(24, 25, 26, 27, 28, 29);

void setup() {
  Serial.begin(9600);
  // SPI.begin();
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  lcd.write("TEST:");
}

void loop() {
  lcd.setCursor(0, 1);
  lcd.print("This is a test");
}

This works perfectly until I uncomment SPI.begin()

For reference, I am using SPI to connect an RFID module. Any ideas as to what might be causing the conflict?

The posted code works fine on my Mega with a 1602 display and the SPI.begin() uncommented. What else is connected to the Mega? And how are the other things wired?

What happens to the display with the SPI.begin() included? What does it show?

I modified your code a bit so that I could see the display updating better by adding a display of millis(). The display works fine and it works the same whether SPI.begin() is commented out or not.

#include <SPI.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(24, 25, 26, 27, 28, 29);

void setup()
{
   Serial.begin(9600);
   SPI.begin();
   lcd.begin(16, 2);
   lcd.setCursor(0, 0);
   lcd.write("TEST:");
   delay(2000);
}

void loop()
{
   static unsigned long timer = 0;
   unsigned long interval = 500;
   if (millis() - timer >= interval)
   {
      timer = millis();
      lcd.setCursor(0, 0);
      lcd.print("This is a test");
      lcd.setCursor(0, 1);
      lcd.print(millis());
   }
}

groundFungus:
The posted code works fine on my Mega with a 1602 display and the SPI.begin() uncommented. What else is connected to the Mega? And how are the other things wired?

What happens to the display with the SPI.begin() included? What does it show?

I modified your code a bit so that I could see the display updating better by adding a display of millis(). The display works fine and it works the same whether SPI.begin() is commented out or not.

#include <SPI.h>

#include <LiquidCrystal.h>

LiquidCrystal lcd(24, 25, 26, 27, 28, 29);

void setup()
{
  Serial.begin(9600);
  SPI.begin();
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  lcd.write("TEST:");
  delay(2000);
}

void loop()
{
  static unsigned long timer = 0;
  unsigned long interval = 500;
  if (millis() - timer >= interval)
  {
      timer = millis();
      lcd.setCursor(0, 0);
      lcd.print("This is a test");
      lcd.setCursor(0, 1);
      lcd.print(millis());
  }
}

Hi - thanks for the reply.

I should have mentioned that I also have an RFID-RC522 module connected to the SPI pins 50-53.

When SPI.begin() is included, the display blinks once turns off (no backlight or text).