Code Monkey home page Code Monkey logo

Comments (4)

fpistm avatar fpistm commented on June 9, 2024

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

from arduino_core_stm32.

xiezhoubin avatar xiezhoubin commented on June 9, 2024

``> 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);
}

from arduino_core_stm32.

xiezhoubin avatar xiezhoubin commented on June 9, 2024

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"

from arduino_core_stm32.

fpistm avatar fpistm commented on June 9, 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.

from arduino_core_stm32.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.