LCD stops working if Ethernet.begin(...) is called

I'm wondering if anyone can shed some light on this, because I'm totally stumped.

I have an Arduino Mega 2560 that I am using as a MODBUS device using an Ethernet Shield 2 and the Modbus library from the official website. I also have an LCD 1602 that is being driven by the Arduino.

Each of these, the Modbus functionality and the LCD, individually works. I can read and write holding registers over TCP. I can print text to the LCD screen. But I can't do both.

I've narrowed it down to Ethernet.begin(mac, ip). If I comment that out, the LCD works. If I leave it uncommented, the LCD is blank but the network communication works.

I'm using pins 52, 50, 48, 45, 43, 41, 39 to drive the LCD (4 data pins). There should be no conflict with the ethernet shield as the shield does not connect to any of these.

google for

https://www.google.com/search?client=firefox-b-d&q=arduino+mega+spi+pins

and you will see immediately whats the problem, ...

Aha! Yes, I did see that Ethernet.begin() does use SPI (the SPI.begin/endTransaction() calls). So that's what it was, pins 50-52 are no good.

Thanks for your help.

@mwerezak

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.