What is the highest working frequency for SPI

Has anyone tested how fast SPI bus can go?

SPI0 & SPI1 (master mode only) works reliable with up to 40 MHz clock.
SPI2 (slave mode only) also works up to 40 MHz (tested mostly with maximal clock of 26 MHz).
SPI3 (connected to SPI Flash) should work up to 100 MHz, I’ve tested only with maximal clock od 83 MHz).

Tested with K210 <-> K210, K210 <-> ESP32 and K210 <-> STM32F4.

So you got SPI slave mode working? Great! How did you do that? In micropython?

I want to send image data from a rpi to my maix board.

(https://maixpy.sipeed.com/en/libs/machine/spi.html states that SPI2 and slave mode are not implemented)

I have a modified FreeRTOS SPI driver which is used from my MicroPython for K210 port, but can also be used from any K210 project based on FreeRTOS SDK (SPI driver source).
The SPI slave on SPI2 works wery well and is quite flexible. I’m using it, for example, to communicate with ESP32 to implement very fast WiFi connection. It should work with RPi without issues.

BTW, my MicroPython for K210 will be updated today or tommorow with many improvements and new features…

1 Like

Hey, that’s absolutely great. I’m still very new to micropython and the K210 (just got the board a few days ago).
My goal is to use face recognition to enable the door opener for my wife (we have a fingerprint sensor, but it doesn’t work for my wife).
So, I have an openhab on a raspberry pi rubbing beautifully. My idea is that the rpi gets a number of pictures from the door cam, seems them via SPI to the m1n board, which then respond with the info if the face was recognized. If yes, the rpi can send the command to open the door.

I will have a look at your repo. I hope I can use it for this.

Thanks for your help!

Wow, I just looked at your repo. That’s an incredible amount of work! I guess it will probably help me a lot.

Thanks for your work! I sent you a donation. :slightly_smiling_face:

I don’t quite understand why would you use RPy - Maix board combination for the task.
If you already have a RaspberryPi, it could do it alone. There are many articles describinn how to do that, like
Use a Raspberry Pi camera and a solenoid lock to create a door lock that unlocks when it recognizes your face
How to Train your Raspberry Pi for Facial Recognition
Facial-Recognition-Attendance-System
etc.

Thank you very much for the donation!

I have seen those, but they are all very slow (0.3-1 fps). I would like to check at least some 5 images, before I open the door. The K210 can do that in real time and also some other fancy stuff (liveness detection). Even with the SPI transfer , it should be possible to get some 5fps, and this with minimal cpu resources on the rpi side.

So, in general, I want to use the m1n with its KPU as a fast coprocessor to the rpi. :smiley:

Ehmm, did I read that correctly on the build page in the wiki that your micropython version does not include the KPU module? :flushed:

Then it would be useless for me :weary: