Skip to content

Program gets stuck, when set SCLK with PD1 on STM32G071 #1901

@Eddddddddy

Description

@Eddddddddy

Describe the bug
The problem is simple, I use STM32G071GBU6, using SPI to connect the sensor.
The IO configuration of SPI is as follows:

  SPI.setMISO(PA3);
  SPI.setMOSI(PA4);
  SPI.setSCLK(PD1);
  SPI.setSSEL(PD0);

This configuration is supported in STM32CUBEMX. And this IO configuration is also supported in the PeripheralPins.c file.
The problem I'm having is that as long as SCLK is configured as PD1, the program gets stuck when it executes to read the SPI. If I replace PD1 with other pins, it will not get stuck, and I can read and write SPI data normally.

To Reproduce
Using SPI example (DigitalPotControl.ino)

// inslude the SPI library:
#include <SPI.h>


// set pin 10 as the slave select for the digital pot:
const int slaveSelectPin = 10;

void setup() {
  // set the slaveSelectPin as an output:
  Serial.begin(9600);
  pinMode(slaveSelectPin, OUTPUT);
  // initialize SPI:
  SPI.setMISO(PA3);
  SPI.setMOSI(PA4);
  //  SPI.setSCLK(PB8);
  SPI.setSCLK(PD1);
  SPI.setSSEL(PD0);
  SPI.begin();
}

void loop() {
  Serial.println("running");
  digitalPotWrite(0, 1);
}

void digitalPotWrite(int address, int value) {
  // take the SS pin low to select the chip:
  digitalWrite(slaveSelectPin, LOW);
  //  send in the address and value via SPI:
  SPI.transfer(address);
  SPI.transfer(value);
  // take the SS pin high to de-select the chip:
  digitalWrite(slaveSelectPin, HIGH);
}

Expected behavior
Serial will print 'running' without stopping with PD1.

Desktop (please complete the following information):

  • OS: macOS 13.1
  • Arduino IDE version: 1.8.19
  • STM32 core version: 2.3.0
  • Tools menu settings if not the default:

image

  • Upload method: SWD

Board (please complete the following information):

  • Name: Custom G071

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions