board707 / w80x_arduino

w806 package for Arduino IDE
GNU Lesser General Public License v2.1
68 stars 12 forks source link

SPI issues #25

Open RudolphRiedel opened 1 year ago

RudolphRiedel commented 1 year ago

I am just playing with a W806 board and SPI. I intend to look deeper but this is what I found now.

I have this little sketch:

include

include

define EVE_CS PB10

define EVE_PDN PB11

void setup() { pinMode(EVE_CS, OUTPUT); digitalWrite(EVE_CS, HIGH); pinMode(EVE_PDN, OUTPUT); digitalWrite(EVE_PDN, LOW);

SPI.begin(); / sets up the SPI to run in Mode 0 and 1 MHz / SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0)); }

void loop() { delay(2);

digitalWrite(EVE_CS, LOW); SPI.transfer(0x55); SPI.transfer(0xaa); SPI.transfer(0x55); digitalWrite(EVE_CS, HIGH);

digitalWrite(EVE_CS, LOW); uint32_t buffer = 0x55aa55aa; SPI.transfer(&buffer, 3); digitalWrite(EVE_CS, HIGH); }

And this is what I get in the logic analyzer: grafik

So well, on a quick glance everything is working, there are a couple of issues though.

grafik grafik grafik

I'll have a look to see what can be done about this.

AnatolSher commented 1 year ago

Hello image Default SS pin image Doc - https://github.com/board707/w80x_arduino/blob/hal-v0.6.0/doc/SPI.md

digitalWrite(EVE_CS, HIGH); digitalWrite(EVE_CS, LOW); It takes a lot of time

When we select 20MHz for SPI, it means base peripheral clock frequency is 40mHz/prescaler image As a result, we have a max spi clock frequency of 20 Mhz

Possible values ​​for spi clock are image

If you need more see workaround in SDIO_TFT_Test folder

RudolphRiedel commented 1 year ago

Thanks for pointing out that SPI.md

Yes, I just worked thru SPI.cpp, reformatted it to a more consistence style and translated the few russian comments. And while it is still working I noticed the limitations and switched to 10MHz which is working.

The pauses got a bit shorter with the increased SPI clock.

grafik

I will need a software controlled CS, so I just continue to use it.

board707 commented 1 year ago

I noticed the limitations and switched to 10MHz which is working.

Yes, the package probably lacks clear style and detailed documentation. However, as far as I understand, the problem is generally solved?

RudolphRiedel commented 1 year ago

Nah, it's still rather slow, especially for a 240MHz core. But that may be something to fix here: https://github.com/IOsetting/wm-sdk-w806/blob/main/platform/drivers/wm_spi.c Well, or with register based code in SPI.cpp.

I'll have a look, but not right away.

board707 commented 1 year ago

But that may be something to fix here: https://github.com/IOsetting/wm-sdk-w806/blob/main/platform/drivers/wm_spi.c

Our code based on the exact this file. But anyway, it will be useful if you look on it again