Hardware SPI

Working libraries, libraries being ported and related hardware
stevestrong
Posts: 1442
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Hardware SPI

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

Image
:D

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

Re: Hardware SPI

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

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

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

Re: Hardware SPI

Post by BennehBoy » Sun Feb 05, 2017 10:01 pm

Well, this is just very very frustrating.

So I rejigged all the wiring on my main test board to use the hardware SPI and the 8 screens work just fine.... except, after a while 2 of them just fail to display anything.

The MAX31856 won't work sharing on the same bus, but unlike with s/w spi at least it doesn't cause the OLED's just fill with white pixels - I'll see if it works with the OLED's disabled.

Can't imagine I'm going to get SD working too lol.
-------------------------------------
https://github.com/BennehBoy

User avatar
RogerClark
Posts: 6367
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Hardware SPI

Post by RogerClark » Sun Feb 05, 2017 10:38 pm

BennehBoy wrote:
The MAX31856 won't work sharing on the same bus, but unlike with s/w spi at least it doesn't cause the OLED's just fill with white pixels - I'll see if it works with the OLED's disabled.
Why won't it work on the same bus ? SPI, speed, SPI mode ?? or doesnt have a CE pin ?

BTW. How have you physically wired the displays? Star configuration or in parallel daisy chain ?

Generally people seem to suggest the daisy chain approach.

Also at these sort of frequencies, (tens of MHz), length of wire becomes important. Wires need to be kept as short as possible.
Bread board are also problematic for big projects, as they are more capacitive than a PCB.

How do you intend to wire it up when the unit was in the car. Birdsnest wiring ?

You can get custom PCB's made really cheaply. You may want to design your own PCB for this.

Re: Displays failing

Did you try swapping the locations of those that failed and those that didnt ?

Sounds like they got a glitch of bad config and after that they would need to be re-initialised.

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

Re: Hardware SPI

Post by BennehBoy » Sun Feb 05, 2017 10:44 pm

They're daisy chained.

I figured out why some of the screens were going blank, software spi code in the library initialises the CS pins and writes them high.

Adding CS pin initialisation and writing them all high fixed that for HW SPI.

Still working on the MAX31856 problem.

Will be moved onto custom strip board with interconnects as short as possible, SPI bus speed will be adjusted for the fact that the head unit needs to be dangled off the end of an ~ 60cm ribbon cable (works fine at 8mhz on the Arduni Nano that's in vehicle presently I might add).
-------------------------------------
https://github.com/BennehBoy

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

Re: Hardware SPI

Post by BennehBoy » Sun Feb 05, 2017 10:53 pm

Is it possible that I need to initialise MISO? I see commented out SS intialisations in SPI.cpp but I guess this it to allow those SS pins to be re-used for other purposes - for example I use SPI 1 SS as an analogue input...

the STM32F1 SPI.h includes <libmaple/spi.h> - this header file is not in the libmaple core folder??

I'm probably missing something obvious
-------------------------------------
https://github.com/BennehBoy

User avatar
RogerClark
Posts: 6367
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Hardware SPI

Post by RogerClark » Mon Feb 06, 2017 4:03 am

BennehBoy wrote:Is it possible that I need to initialise MISO? I see commented out SS intialisations in SPI.cpp but I guess this it to allow those SS pins to be re-used for other purposes - for example I use SPI 1 SS as an analogue input...

the STM32F1 SPI.h includes <libmaple/spi.h> - this header file is not in the libmaple core folder??

I'm probably missing something obvious
The STM32 has some issues with the use of the SS (NSS) pin.
The way it works as hardware SPI chip select, does not correspond with what most people expect (not just Arduino STM32 users, people using the Standard peripheral lib etc as well - there are plenty of posts on other forums about this)

We try to re-assign it back to a GPIO in the library or the core (I can't recall quite where the code is), but I'm not 100% convinced we suceeded from detaching it from its internal connection to the SPI hardware block.

But if it works for you as analogue, then I'd carry on using it.

Re: Speed and cable length

OK. I run my ILI9341 displays, overclocked at 36Mhz and have had issues on long lengths of ribbon cable.

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

Re: Hardware SPI

Post by stevestrong » Mon Feb 06, 2017 8:25 am

In SPI master mode the SS pin is left up to the user to configure (to output mode) and to use (set low before transfer and set high after that). But any GPIO can thus be used.
In slave mode it is needed and configured automatically by the SPI hw to detect external SS, but not tried what happens if you re-configure it after SPI slave initialisation.

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

Re: Hardware SPI

Post by BennehBoy » Mon Feb 06, 2017 8:29 am

stevestrong wrote:In SPI master mode the SS pin is left up to the user to configure (to output mode) and to use (set low before transfer and set high after that). But any GPIO can thus be used.
In slave mode it is needed and configured automatically by the SPI hw to detect external SS, but not tried what happens if you re-configure it after SPI slave initialisation.
Thanks, makes sense.
-------------------------------------
https://github.com/BennehBoy

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

Re: Hardware SPI

Post by BennehBoy » Mon Feb 06, 2017 8:31 am

RogerClark wrote: But if it works for you as analogue, then I'd carry on using it.
I worry that because I'm new to this and don't have a deep knowledge, I may fall into the trap of using something 'that works' but only does so as an unintended consequence which will ultimately lead to things breaking in future or 'working' intermittently.

Ah the joys :D

Regarding the libmaple spi.h should I worry that I can't find it? Is that code already compiled to object form so the linker works just fine? Again am I completely misunderstanding things?
-------------------------------------
https://github.com/BennehBoy

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest