SPI working on STM32F401, not on STM32F405

Post here first, or if you can't find a relevant section!
User avatar
Bakisha
Posts: 139
Joined: Fri Dec 20, 2019 6:50 pm
Answers: 5
Contact:

Re: SPI working on STM32F401, not on STM32F405

Post by Bakisha »

Actually, this thread helped me finally figure out why my ST7735 wasn't working so far on my STM32F411CE with Adafruit library:

Working:

Code: Select all

#define TFT_DC       PA_3 
#define TFT_CS       PA_4
#define TFT_RST     PA_2
#define TFT_SCLK    PA_5
#define TFT_MISO    PA_6
#define TFT_MOSI    PA_7
Not working:

Code: Select all

#define TFT_DC       PA3 
#define TFT_CS       PA4
#define TFT_RST     PA2
#define TFT_SCLK    PA5
#define TFT_MISO    PA6
#define TFT_MOSI    PA7
Thanks!
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: SPI working on STM32F401, not on STM32F405

Post by fpiSTM »

@Bakisha
Seems strange as PYn is the pin number while PY_n is the PinName all standard Arduino API uses pin number. Some few extra API use directly PinName.
it works for @mrguen as it uses the SPI.setXXX which handles both notations.
User avatar
Bakisha
Posts: 139
Joined: Fri Dec 20, 2019 6:50 pm
Answers: 5
Contact:

Re: SPI working on STM32F401, not on STM32F405

Post by Bakisha »

@fpiSTM
I don't think i has anything to do with SPI.
If called by hardware SPI,

Code: Select all

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
then it only needs

Code: Select all

#define TFT_DC PA_3 
#define TFT_CS PA_4
#define TFT_RST PA_2
to be able to work (example sketches from library).
I can't say why, i'm just glad that @mrguen posted both non-working and working sketches, so i was able to spot and test difference.
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: SPI working on STM32F401, not on STM32F405

Post by fpiSTM »

@Bakisha
I didn't tell it is linked to SPI, just an example.
Anyway, there is a mistake here as PY_n should not be used in your case... or with a lot of luck they have the same value PYn == PY_n which is highly improbable.
PYn is converted to PY_n. So if PY_n is used then it is converted to another value or a default error value.
mrguen
Posts: 24
Joined: Tue Mar 03, 2020 1:21 pm
Answers: 2

Re: SPI working on STM32F401, not on STM32F405

Post by mrguen »

Frankly, I was far from the theory. I wanted to be coherent and use the #define in the Pin configuration table. Using the pin number was throwing a compilation error so I changed everything to pin names.
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: SPI working on STM32F401, not on STM32F405

Post by fpiSTM »

mrguen wrote: Tue May 11, 2021 4:53 pm Frankly, I was far from the theory. I wanted to be coherent and use the #define in the Pin configuration table. Using the pin number was throwing a compilation error so I changed everything to pin names.
Frankly, I know. And IMHO your are not coherent that's probably why you have so much (false) "issue" :mrgreen:
mrguen
Posts: 24
Joined: Tue Mar 03, 2020 1:21 pm
Answers: 2

Re: SPI working on STM32F401, not on STM32F405

Post by mrguen »

fpiSTM wrote: Tue May 11, 2021 4:16 pm @Bakisha
Seems strange as PYn is the pin number while PY_n is the PinName all standard Arduino API uses pin number. Some few extra API use directly PinName.
it works for @mrguen as it uses the SPI.setXXX which handles both notations.
Well if you consider that "PA_10" might be different than "PA10" ... well we don't have the same understanding of the word "coherence". And concerning the code I submitted, using the "pin number" results in a compilation error, because IMHO there is no coherence between the pin definition files and the "standard" coding using pin numbers.
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: SPI working on STM32F401, not on STM32F405

Post by fpiSTM »

mrguen wrote: Tue May 11, 2021 7:46 pm Well if you consider that "PA_10" might be different than "PA10" ... well we don't have the same understanding of the word "coherence".
PinName value are the same for all variants

Code: Select all

  PA_0  = (PortA << 4) + 0x00,
while PA0 is defined for each variant and can have different value.

Code: Select all

#define PA0 0
mrguen wrote: Tue May 11, 2021 7:46 pm And concerning the code I submitted, using the "pin number" results in a compilation error, because IMHO there is no coherence between the pin definition files and the "standard" coding using pin numbers.
Well, without log nor full sketch hard to tell what's you made wrong.
Anyway I guess here we add not the same definitions. If "pin definition files" is PeripheralPins.c it is not correct, it is simply a database of all capabilities of a pins.
Post Reply

Return to “General discussion”