Page 1 of 1

STM32L4 Alternate SPI function for PA15

Posted: Sun Jun 04, 2023 8:09 pm
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.

Re: STM32L4 Alternate SPI function for PA15

Posted: Fri Jun 23, 2023 4:14 am
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