Hardware SPI

Working libraries, libraries being ported and related hardware
User avatar
BennehBoy
Posts: 418
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: Hardware SPI

Post by BennehBoy » Sat Feb 04, 2017 4:59 pm

So, the library doesn't work properly on a Nano clone either, it rotates the entire display 1 byte right each time it's drawn, as though it's incorrectly xferring an extra byte of the screen buffer.

Sigh.
-------------------------------------
https://github.com/BennehBoy

User avatar
BennehBoy
Posts: 418
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: Hardware SPI

Post by BennehBoy » Sat Feb 04, 2017 8:39 pm

Well, I'm an idiot.

For some reason I had it in my head that the DC pin on the screens was MISO, au contraire it's simply a signal to tell the display to expect a command.

So HW SPI works on the Nano afterall.

Still can't make it work on the Maple Mini - even after making edits to the library (disabling portreg code, and forcing spi mode and clock divider).

I also can't get this code to work -> http://www.stm32duino.com/viewtopic.php?t=357

Software SPI works just fine over the same pins (ie no wiring issue)

Ironically, the reason that my 2 software spi devices probably didn't work together was that I would've been stomping on MISO with the DC line for the SSD1306. If I can't figure out why HW SPI does nothing then I'll likely try that next.
-------------------------------------
https://github.com/BennehBoy

stevestrong
Posts: 1175
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Hardware SPI

Post by stevestrong » Sun Feb 05, 2017 4:30 pm

@BennehBoy, could you be a bit more specific, what does it mean "HW SPI does nothing"?
Can you plot at least one pixel onto the screen? Or at least set background to a color (red)?

I would also recommend to use exclusively the

Code: Select all

SPI.beginTransaction(SPISetting(8000000, ...));
instead of:

Code: Select all

SPI.begin();
SPI.setDataMode(); and so on...

User avatar
BennehBoy
Posts: 418
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: Hardware SPI

Post by BennehBoy » Sun Feb 05, 2017 5:13 pm

No pixels whatsoever, I'll try using the begintransaction change in the library, thanks.
-------------------------------------
https://github.com/BennehBoy

User avatar
BennehBoy
Posts: 418
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: Hardware SPI

Post by BennehBoy » Sun Feb 05, 2017 5:37 pm

Nope Nothing.

Zip file of libraries and code attached. This is just the 'slimmed down' test code. Will compile against Uno/Nano and STM32 - wire accordingly.

Comment/Uncomment lines 75 & 85 to switch between software/hardware SPI

The included Adafrui_SSD1306 library has been edited to remove portreg code & only use begin transaction.

PS. Nano/Uno HW SPI only works if the SPi.begin code is re-enabled in the lib
Attachments
LRDuino.zip
(21.16 KiB) Downloaded 12 times
-------------------------------------
https://github.com/BennehBoy

stevestrong
Posts: 1175
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Hardware SPI

Post by stevestrong » Sun Feb 05, 2017 6:34 pm

My comments:
- I don't see where "_VARIANT_ARDUINO_STM32_" is defined, to use the correct OLED_CS in line 32 of INO.
- I don't see why do you need <Wire.h>. Even in the Adafruit_SSD1306 lib, it is not needed as long you only have SPI connection, so you could remove or #ifdef all of Wire instances.
- try to use "SPI.write(d);" in line 496 of Adafruit_SSD1306.cpp.

Otherwise everything else looks reasonable to me.

As alternative, you could try my version of SPI lib.

User avatar
BennehBoy
Posts: 418
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: Hardware SPI

Post by BennehBoy » Sun Feb 05, 2017 7:42 pm

I'll make the edit and try.

Hmm _VARIANT_ARDUINO_STM32_ worked for me previously, I thought this was defined as part of the core?

I'll just comment out all the conditonals and try as is, to be sure.
-------------------------------------
https://github.com/BennehBoy

User avatar
BennehBoy
Posts: 418
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: Hardware SPI

Post by BennehBoy » Sun Feb 05, 2017 7:47 pm

No change. :(
-------------------------------------
https://github.com/BennehBoy

stevestrong
Posts: 1175
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Hardware SPI

Post by stevestrong » Sun Feb 05, 2017 8:00 pm

- try to use "SPI.write(d);" in line 496 of Adafruit_SSD1306.cpp.

User avatar
BennehBoy
Posts: 418
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: Hardware SPI

Post by BennehBoy » Sun Feb 05, 2017 8:11 pm

<egg on face>
I hereby authorise you to issue a remote punch to my head. :oops: :oops:

I just examined the breadboard and found that the power jumper had fallen out - just found it next to my desk.

Hardware SPI works without any library modifications.
</egg on face>

I truly am an idiot.
-------------------------------------
https://github.com/BennehBoy

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest