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

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

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.

According to the data sheet, the frame frequency is 20 Hz when the clock frequency is 2 MHz. mbed’s hardware SPI throughput is 1/3, so 9 Hz should be sufficient.
Just to confirm, it’s 9Hz in mbed, right?

Wow, that’s awesome. I would be ready to test and help debug.

exactly, yes. 9-10 Hz using mbed and hardware SPI (which shows no output).

(which shows no output)

What do you mean? Does it mean it doesn’t work?