Hardware SPI with Arduino Mega

Hellow together

There is a Problem with hardware SPI with on Arduino Mega and I need some help.

I already work with an Arduino DUE using hardware SPI Hardware SPI with
sclk=76, data=75
for the communication to an QVGA Display.

Therefore I include SPI.H and Ucglib.h
using
Ucglib_ILI9341_18x240x320_HWSPI ucg(/cd=/ 26 , /cs=/ 24, /reset=/ 22);
It works really quick and fine.

Then I try the same with an Arduino Mega changing Hardware Pins to
sclk=52, data=51; including SPI.H and Ucglib.h
using
Ucglib_ILI9341_18x240x320_HWSPI ucg(/cd=/ 26 , /cs=/ 24, /reset=/ 22);
and of course I use an 4050 level shifter.
Setting
pinMode(53, OUTPUT);
digitalWrite(53, HIGH);

but nothing works at all.

If I change to software SPI with
Ucglib_ILI9341_18x240x320_SWSPI ucg(/sclk=/ 52, /data=/ 51, /cd=/26 , /cs=/ 24, /reset=/22);

it works but only very slowly.

who is familiar with hadware SPI on Arduino Mega and can help me?

Arduino Mega SPI pins: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS).

If you don't use MISO, the slave can't respond to the master.

Also a possible:

Note about Slave Select (SS) pin on AVR based boards

All AVR based boards have an SS pin that is useful when they act as a slave controlled by an external master. Since this library supports only master mode, this pin should be set always as OUTPUT otherwise the SPI interface could be put automatically into slave mode by hardware, rendering the library inoperative.

It is, however, possible to use any pin as the Slave Select (SS) for the devices. For example, the Arduino Ethernet shield uses pin 4 to control the SPI connection to the on-board SD card, and pin 10 to control the connection to the Ethernet controller.

And lastly the speed. Crank it down to 8000000 or 4000000 and no more than 16000000.

On Mega, default speed is 4 MHz (SPI clock divisor at 4). Max is 8 MHz (SPI clock divisor at 2).

It's probably the same for most if not all AVR's running at 16MHz.

That 4MHz is bits per second, 500K chars/sec as opposed to 115200 baud = 11520 chars/sec. SPI has no start and stop characters.

But wait!

If your SPI scheme transfers data from slave to master as the master transfers data out, you get double throughput out of SPI. Technically you could get 2MB/sec through SPI.

Thank you for yor help.

I crank down the speed to 4000000

SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));

But it still did not work.

I had no transfer of data from slave to master.

Did you connect pin 50 (Master IN Slave OUT)?

Yes i did so not knowing for what that can help, cause there is no comminication from Slave to Master

Eyck:
Yes i did so not knowing for what that can help, cause there is no comminication from Slave to Master

Just looking for places where a problem may occur.

MISO is the line you need. Is it connected right at the device end?

The Mega2560 runs at 5V while the Due runs at 3.3V. Was the 4050 needed with the Due or the Mega?

Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/ 26 , /*cs=*/ 24, /*reset=*/ 22);

Does that have a return of any kind?

Thank you for helping me.

Why do I need the MISO line if there is no date from slave to Master?
I think MISO is Master In Slave Out.

For communication to the Display I only need MOSI Master Out Slave In,
cause the Display is the slave.

I only use the 4050 for the Mega 2560.

Of course I connect the MISO as well but things did not change.

With or without connecting the MISO line communication works with
software SPSI without changing any hardware connection.

sorry writing mistake, it must be
software SPI in th last Line