Nucleo-F030R8 Hardware SPI Pins

All about boards manufactured by ST
GeorgeIoak
Posts: 39
Joined: Sun Jun 07, 2020 2:01 am

Nucleo-F030R8 Hardware SPI Pins

Post by GeorgeIoak »

I have one of these boards and I'm trying to use it with the Arduino IDE and Adafruit ILI9341 library which is for a SPI LCD. The LCD and code works when tested with a Adafruit STM32F405 Feather but when I switch the hardware to Nucleo-F030R8 board I cannot get the LCD to work.

From what I can tell the SPI signals should be:

SPI1-SCK -- PA5 --D13
SPI1-MOSI --PA7 -- D11
SPI1-CS -- PA4 -- D10

The code that I use to initial the LCD is:

Code: Select all

#define TFT_DC 9 //PB8
#define TFT_CS 10 //PB9
// Use hardware SPI and the above for CS/DC
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
I believe something is wrong with the SPI module or maybe the clock configuration but I can't seem to find anything wrong. I reset the board and tried to check most of the pins with the scope to see if I was just misunderstanding which pins are mapped on the F030R8 but I never could find the clock signal.

Does anyone have any ideas what I can do to find out what is wrong?
GeorgeIoak
Posts: 39
Joined: Sun Jun 07, 2020 2:01 am

Re: Nucleo-F030R8 Hardware SPI Pins

Post by GeorgeIoak »

I forgot to mention that I'm using the "official" core
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Nucleo-F030R8 Hardware SPI Pins

Post by fpiSTM »

GeorgeIoak
Posts: 39
Joined: Sun Jun 07, 2020 2:01 am

Re: Nucleo-F030R8 Hardware SPI Pins

Post by GeorgeIoak »

Yes, I see that and my comment was left over from when I was using the STM32F405 Feather board. But if I physically connect the LCD's CD pin the board's D10 and pass 10 into the Adafruit_ILI9341 definition shouldn't that still work? It's just the chip select so I would think any pin could be used for the enable signal?

Looking at the schematic in the user manual, https://www.st.com/resource/en/user_man ... ronics.pdf on page 66 I see that:

D13 is connected to PA5 through SB42
D12 is connected to PA6 through SB41
D11 is connected to PA7 through SB40

Aren't those the default Arduino UNO SPI pins that this board is supposed to "emulate"?
GeorgeIoak
Posts: 39
Joined: Sun Jun 07, 2020 2:01 am

Re: Nucleo-F030R8 Hardware SPI Pins

Post by GeorgeIoak »

Why are PA6 and PA7 defines as A6 and A7?
variants.h#L41-L42

Looking at the schematic SB41/SB40 are normally closed and that sends PA6/7 to D12/D11

SB39/SB36 are normally open BUT if they were closed they would send PA6/7 to CN10 pins 28/26

So I think the definition in the variants file is defining D12/D11 to analog inputs and that is not the default connection.

I tried changing the variants.h file on my computer to assign PA7 to D11 (MOSI) and PA6 to D12 (MISO) but that didn't help solve my issue.
GeorgeIoak
Posts: 39
Joined: Sun Jun 07, 2020 2:01 am

Re: Nucleo-F030R8 Hardware SPI Pins

Post by GeorgeIoak »

Problem solved. Dumb software problem on my part. When I switched to the Nucleo board I didn't connect up a sensor that I had on the STM32F405 Feather. I forgot I had a `while(1)` loop inserted if the sensor wasn't found. Sorry for the wasted efforts.

I am confused about the A6/A7 assignments though so I'd appreciate some clarification on that please.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Nucleo-F030R8 Hardware SPI Pins

Post by fpiSTM »

GeorgeIoak wrote: Sun Jun 07, 2020 8:51 pm Problem solved. Dumb software problem on my part. When I switched to the Nucleo board I didn't connect up a sensor that I had on the STM32F405 Feather. I forgot I had a `while(1)` loop inserted if the sensor wasn't found. Sorry for the wasted efforts.

I am confused about the A6/A7 assignments though so I'd appreciate some clarification on that please.
Fine you solved your issue.
About A6 and A7 this means that the pins have analog capabilities but this is also a digital pins:
PA7 == D11 == A6 == 11
PA6 == D12 == A7 == 12

So doing:
analogRead(PA7) == analogRead(D11) == analogRead(6) == analogRead(A6)
digitalRead(PA7) == digitalRead(D11) == digitalRead(11) == digitalRead(A6)

And the pins can also be used for SPI and all other alternate function available, PA7 has TIM3 capability so you can also generate a PWM.
GeorgeIoak
Posts: 39
Joined: Sun Jun 07, 2020 2:01 am

Re: Nucleo-F030R8 Hardware SPI Pins

Post by GeorgeIoak »

Thank you again. TBH, I started with MCUs long before Arduino and Raspberry Pi and renaming pins may help new people for me it's just confusing with all the different names. I wish they would have just "made" new people learn how ports and pins are defined and how to set the mode and alternate functions of those pins.
PA7 == D11 == A6 == 11
And then sometimes I even see PA_7.

Sorry, I just had to say that!

Back to the A6/A7, did those pins get "defaulted" to A6/A7 just to show that there are more analog input pins available? It just seems a bit odd since those are the default pins used for SPI in Arduino (I believe this is true) so I would have expected to see that definition.

Finally, have I missed some documentation that explains all the pin numbering choices and how you find out which ones are available for each board or do you look at variant.h to find the definitions?
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Nucleo-F030R8 Hardware SPI Pins

Post by fpiSTM »

As said A6 and A7 is just the Arduino naming for pins with analog capabilities.
All analog pins are aslo a digital one. And so they are also the D11/D12 in a Arduino naming conventions.
Fie new user, simply follows Arduino naming (the same on the silkscreen) and they should work.
First gola of the core is to be Arduino compatible. It has been extended to provide more support and also extra feature.
I'm agree some documentations are missing mainly for the pin naming, look at the variant.h provide the full pin descriptions.
GeorgeIoak
Posts: 39
Joined: Sun Jun 07, 2020 2:01 am

Re: Nucleo-F030R8 Hardware SPI Pins

Post by GeorgeIoak »

Yes, sorry, I completely understand that A6 and A7 are the Arduino naming for analog pins. I'm just curious why in variants.h they aren't called D11/D12 which, from what I can tell, is what all the Arduino boards use and that is what is on the Nucleo-F030R8 silk screen.

That is what made me question how those pins were actually defined "under the hood". I expected those to default to being digital pins so when I saw A6/A7 I figured that they must have been defined as analog input pins and that's why my SPI wasn't working.

Was this just someone's choice to label these A6/A7 instead of D11/D12? Is there a reason why they weren't called D11/D12 like "standard" naming?
Post Reply

Return to “STM boards (Discovery, Eval, Nucleo, ...)”