SPI not working with MBED (was: Performance of XIAO with Sharp Memory Display)

There is another big difference in the waveforms: The mbed clock pins are set to “low power”, so the waveforms are not properly square. The non-mbed pins are set to “high power”, so they are properly square. This is just a guess, it may be that the Sharp input pins do not accept the mbed waveform.
I think there is a way to switch the pin setting to high power, but I don’t think it is easy.

1 Like

and this cannot be easily changed?
I just need a working prototype, and the display I used first is completely unreadable in sunlight which is the only usecase for this application… so I thought “let’s switch to a new display, can’t be that hard”

I think there is a way to switch the pin setting to high power, but I don’t think it is easy.
If anyone has any expertise in this area、we would like some help.

1 Like

what exactly do you mean by that? Did you see this in the code or measure it with an oscilloscope?

measure it with an oscilloscope.

According to the controller datasheet, the maximum frequency of the clock is 2 MHz, the waveform will be a perfect square wave even with mbed.

so the waveform is perfect when using 2MHz, but the signal is to “weak”?

I think the input is CMOS so it shouldn’t need power.

In the case of mbed, the data transfer interval of 20uS is dominant, so even at 2MHz, the throughput will hardly decrease.

What happens if you change the setting back to software SPI and run it with pins other than D8 and D10?

hmm I think then I’m back to post 1, where it “works” but is incredibly slow?
Or did I miss something that would have changed since then?

I used the pins as follows:
D10 for MOSI
D8 for SCK
D4 for SS/CS

You are using pins other than D10 and D8 for MOSI and SCK, right?

Since OLED is working, what about the proposal to change Sharp to OLED?
I bought 128X64 for less than $10.

No, I use D10 for MOSI and D8 for SCK as per https://how2electronics.com/wp-content/uploads/2022/05/Pinout.jpg

I used D4 for SS since I don’t think it makes a difference which one I use?

I had the oled and already tested it in real life. The project depends on being sunlight readable and fast update (so no eink) and the OLED was literally invisible.

Oh, you mean when using softSPI? Yes, I did use 4-6 then

Since D8 and D10 are hardware SPI pins, why don’t you try using pins other than D8 and D10 in software SPI configuration.

sorry I was late, see above. I used D4-D6 for soft SPI.
Or maybe not. It’s late and I’m tired, need to try tomorrow.

Ok resoldered to test it.

#define SHARP_SCK  6
#define SHARP_MOSI 5
#define SHARP_SS   4

Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, SCREEN_WIDTH, SCREEN_HEIGHT, 2000000);

I get around 2Hz like this when using MBED :frowning:
Around 10Hz non-mbed (which would be okay, but using non-mbed still makes me rewrite the whole bluetooth-code which I honestly don’t understand how to… :frowning:

Let’s call it a day.
I don’t have Sharp on hand, so I am limited, but I will give it some thought.

1 Like

I set the clock to 2 MHz and checked the waveform again. 1 byte transfer time is
mbed : 24uS
non-mbed : 8.5uS
The throughput of mbed is about 1/3. The frame rate difference may be the correct result.

I’m also working on a “2-peripheral” version using non-mbed, but I do not even know if it is possible to expand to “2-peripheral” in the first place. I still need more time.

You mean using the Bluefruit-library?
I think there is even an example for this in Adafruit Bluefruit NRF52 libraries → Central → central_bleuart_multi

I may give it a go in the next hours as well…

would you expect the hardware SPI on mbed to work normally or also slowed down? I mean, do you expect the limitation to only affect soft SPI?

so I just integrated everything into my codebase again and switch back and forth between hard and soft SPI.

Using soft SPI, I get around 1.5Hz, with hard SPI, I get almost exactly 9Hz - which would look good enough, if I would get any output using the hard SPI-pins.

If you PM me your address, I’m going to gift you one.

You mean using the Bluefruit-library?

Yes.
It is a totally non-mbed prototype, but I was able to connect two peripherals and transfer data. Still needs to be debugged.

1 Like