Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STM32F030CCT6 PB15 GPIO Interrupt #2338

Closed
xiezhoubin opened this issue Apr 15, 2024 · 4 comments
Closed

STM32F030CCT6 PB15 GPIO Interrupt #2338

xiezhoubin opened this issue Apr 15, 2024 · 4 comments
Labels
invalid This doesn't seem right

Comments

@xiezhoubin
Copy link

Arduino developed stm32f030cct6, which cannot use PB15 as an external interrupt pin. Once attachInterrupt (digitally PinToInterrupt (PB15), callback, CHANGE) is used; This line of code will cause the program to get stuck here

@fpistm
Copy link
Member

fpistm commented Apr 15, 2024

Hi @xiezhoubin
Could you be more precise?
Sketch? Board used? Core version?....

@fpistm fpistm added this to To do in STM32 core based on ST HAL via automation Apr 15, 2024
@xiezhoubin
Copy link
Author

``> Hi @xiezhoubin Could you be more precise? Sketch? Board used? Core version?....

chip:stm32f030cct6

Core version:2.7.1

code:

#include <Arduino.h>

HardwareSerial mySerial(PA10, PA9);

volatile uint32_t count = 0;
volatile bool flag = false;

void callback() {
  if (flag) {
    count++;
  }
}

void setup() {
  delay(1000);

  mySerial.begin(115200);
  mySerial.setTimeout(5);
  mySerial.println("\n start...");

  pinMode(groundSenseDetectionPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(PB15), callback, CHANGE); 
  mySerial.println("\n ok");
}

void loop() {
  mySerial.println("count:" + String(count));
  delay(100);
}

@xiezhoubin
Copy link
Author

I have tested that the PA5 pin is working and the program can run normally; If it is PB15, the program will get stuck in "attachInterrupt"

@fpistm
Copy link
Member

fpistm commented Apr 15, 2024

Your code could not be built as groundSenseDetectionPin is not declared and not functional as flag is always false. So counter is always 0.

I've tested with the code below and a Nucleo F030R8 as I have no board with F030CC, anyway same series and it works as expected.

// HardwareSerial mySerial(PA10, PA9);
#define mySerial Serial

volatile uint32_t count = 0;
volatile bool flag = false;

void callback() {
  // if (flag) {
    count++;
  // }
}

void setup() {
  delay(1000);

  mySerial.begin(115200);
  mySerial.setTimeout(5);
  mySerial.println("\n start...");

  pinMode(PB15, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(PB15), callback, CHANGE); 
  mySerial.println("\n ok");
}

void loop() {
  mySerial.println("count:" + String(count));
  delay(100);
}

I've also tried with the Nucleo F030R8 hardware but compiling for a Generic F030C8 and same no issue.

How you know it get stuck in attach interrupt, did you try to debug? My guess is the PB15 state always change and the callback is called permanently.
It is linked to your hardware.

@fpistm fpistm closed this as completed Apr 15, 2024
STM32 core based on ST HAL automation moved this from To do to Done Apr 15, 2024
@fpistm fpistm added the invalid This doesn't seem right label Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
Development

No branches or pull requests

2 participants