SPI on STM32F4

Limited support for STM32F4 Discovery, Nucleo and custom F4 boards
User avatar
RogerClark
Posts: 7538
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: SPI on STM32F4

Post by RogerClark » Mon Jun 08, 2015 1:02 am

Re: PAU


OK. I think I've fixed that issue.

I'm not quite sure how, but I had set the forum so some sections (those under the Boards sub section), has assigned "Standard Access" to Guests.
Which meant they could post.
I'm not sure when this happened, probably some time ago, as I recall noticing that the post reply button was visible when I was not logged in, but I was busy at the time and ignored.

So I don't think this was actually a hack.

Anyway, PAU was a guest, who obviously knows how to answer questions on the Arduino.

I will see if I can retrieve PAU's IP Address and get their location.

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

Re: SPI on STM32F4

Post by RogerClark » Mon Jun 08, 2015 1:20 am

OK

I've downloaded the web logs and I've isolated all the IP address of anyone that has posted to this thread.

I just need to cross reference against the known users and then we have PAU's IP address and also lots of great information that their browser has shared to the server ;-)

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

Re: SPI on STM32F4

Post by RogerClark » Mon Jun 08, 2015 1:24 am

OK

I think I have isolated the IP address that posted.

Please PM me if you want it.

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

Re: SPI on STM32F4

Post by RogerClark » Mon Jun 08, 2015 3:17 am

Martin,

You can get the original hardware SPI file from my repo, by looking at the second commit, when I initially added the files.

BTW. I'm not sure if this is the issue you are having, but it looks like NSS (hardware chip select) doesn't work, and whats worse is that it seems to override the GPIO config for PA4 (on F103) for use as chip Select )

I recall that its a known issue that NSS didnt work with LibMaple, but most people didn't care as they didn't want to be restricted to using PA4 as SS (aka CS).
On AVR there isn't an equivalent to NSS, and CS is always done using GPIO by the lib's, Its not handled by the SPI lib, it's normally handled by the libs that use SPI (or sometimes its just handled by the sketch).

Anyway, if you are using PA4 (or the equivalent pin on the F4, - I"m not sure which pin is NSS on the F4), you could try just pulling CS permanently low, or use another pin.

I've found the SD lib works fine now that I have moved the pin (and when I pull it low permanently)

User avatar
martinayotte
Posts: 1234
Joined: Mon Apr 27, 2015 1:45 pm

Re: SPI on STM32F4

Post by martinayotte » Mon Jun 08, 2015 10:02 pm

Hi Roger,
That was it, although I don't completely understand the NSS issue.
I thought NSS and CS was the same pin, so reading the other thread and your reply above, I decided to change the #define BOARD_SPI3B_NSS_PIN in discovery_f4.h to a different pin than the actual CS on Netduino, and SD lib start working since I've initialized the CS pin myself.
So, it is now a step further ! :)
Next challenge is to try the ENC28J60 with the same method and try to get the networking running. ;)

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

Re: SPI on STM32F4

Post by RogerClark » Mon Jun 08, 2015 10:32 pm

Martin

This sounds like the same bug on both processors

I will sort out a fix on F1 and let you know what needs to change on the F4

User avatar
martinayotte
Posts: 1234
Joined: Mon Apr 27, 2015 1:45 pm

Re: SPI on STM32F4

Post by martinayotte » Mon Jun 08, 2015 11:10 pm

Hi Roger,
I presume that the real fix need to be done at the lowest level as possible to avoid having to do pinMode() on every libraries which are calling begin().
So, maybe it should be done in the begin() itself ?

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

Re: SPI on STM32F4

Post by RogerClark » Mon Jun 08, 2015 11:39 pm

Martin

Yes. I intended to put the fix in SPI.begin()

Actually I could put it in the spi init low level functions called by begin() but I need to work out the best location to put this so it doesnt keep getting called multiple times during the setup process

Post Reply