STM32L4 Alternate SPI function for PA15

Post here first, or if you can't find a relevant section!
Post Reply
Arduser
Posts: 1
Joined: Sun Jun 04, 2023 8:02 pm

STM32L4 Alternate SPI function for PA15

Post by Arduser »

Hello,

I want to use PA15 as chip select, but can't get it to even change state to high by using:

Code: Select all

  pinMode(PA15, OUTPUT);
  digitalWrite(PA15, HIGH);
I can't find any information why the below would not work on STM32L4? SPI data and clock are ok, but the chip select remains low. Is there some other function I should be using?

Code: Select all

#include <SPI.h>

void setup() {

  LL_GPIO_SetAFPin_8_15(GPIOA,LL_GPIO_PIN_15,LL_GPIO_AF_5);
  LL_GPIO_SetPinMode(GPIOA,LL_GPIO_PIN_15,LL_GPIO_MODE_OUTPUT);

  Serial.begin(57600);

  SPI.setMISO(PA6);
  SPI.setMOSI(PA7);
  SPI.setSCLK(PA5);
  SPI.setSSEL(PA15);

  //pinMode(PA15, OUTPUT);
  //digitalWrite(PA15, HIGH);

  SPI.begin();

  delay(100);
}

void loop() {

  SPI.transfer(0x7E);

  delay(1000);
}
I did notice an earlier post suggesting:
https://github.com/stm32duino/Arduino_C ... .h#L68-L85
But it doesn't seem to do anything differently on L4's.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: STM32L4 Alternate SPI function for PA15

Post by fpiSTM »

If you do SPI.setSSEL(PA15) then library is in charge of the hardware CS pin so check if PA15 is the SSEL part of the SPI IP you used.
See the wiki: https://github.com/stm32duino/Arduino_C ... ki/API#spi
Post Reply

Return to “General discussion”