Git Product home page Git Product logo

Comments (9)

maxgerhardt avatar maxgerhardt commented on August 21, 2024 2

Can I ask you to pio pkg update -g -p gd32 again and test your original sketch, still without hardware pullups? I've tried to fix the bug in 5593435.

from arduinocore-gd32.

maxgerhardt avatar maxgerhardt commented on August 21, 2024 1

Could you remove the hardware pullups again and try this suggestion about the switched order?

#include <Arduino.h>

HardwareSerial Serial(PB7, PB6, 0);

void pinDidChange() {
Serial.println("pinDidChange");
}

void prepare() {
attachInterrupt(digitalPinToInterrupt(PA8), pinDidChange, CHANGE);
attachInterrupt(digitalPinToInterrupt(PA9), pinDidChange, CHANGE);
attachInterrupt(digitalPinToInterrupt(PA10), pinDidChange, CHANGE);
}

void setup() {

Serial.begin(115200);
Serial.println("EC11 Test");
// first setup interrupt (inits pin to "INPUT(_FLOATING)"
prepare();
// then activate their pullups
pinMode(PA9, INPUT_PULLUP);
pinMode(PA8, INPUT_PULLUP);
pinMode(PA10, INPUT_PULLUP);
}

void loop() {

delay(10);
// put your main code here, to run repeatedly:
}

from arduinocore-gd32.

flute2k3 avatar flute2k3 commented on August 21, 2024 1

work like a charm, thank you !

from arduinocore-gd32.

maxgerhardt avatar maxgerhardt commented on August 21, 2024

With what platformio.ini is that exactly for reference?

We previously did have issues with pin modes being incorrect but I was convinced they're all properly fixed now in this file.

When you only do pinMode(PA9, INPUT_PULLUP);, as the only command in setup() and nothing in loop(), is the pullup still off? We could have a bug in attachInterrupt that resets the input mode back to INPUT after all. Exchanging the order of prepare() and pinMode(PA9, INPUT_PULLUP); may be a workaround for this, but if that's true, then it's a bug.

from arduinocore-gd32.

maxgerhardt avatar maxgerhardt commented on August 21, 2024

Yes it's exactly like this. We have a bug.

void gpio_interrupt_enable(uint32_t portNum, uint32_t pinNum, void (*callback)(void), uint32_t mode)
{
exti_line_enum exti_line = BIT(pinNum);
exti_mode_enum exti_mode = EXTI_INTERRUPT;
exti_trig_type_enum trig_type = mode;
gpio_exti_infor[pinNum].callback = callback;
gpio_clock_enable(portNum);
#if defined(GD32F30x) || defined(GD32E50X)
rcu_periph_clock_enable(RCU_AF);
gpio_init(gpio_port[portNum], GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, gpio_pin[pinNum]);
#elif defined(GD32F3x0) || defined(GD32F1x0)
rcu_periph_clock_enable(RCU_CFGCMP);
gpio_mode_set(gpio_port[portNum], GPIO_MODE_INPUT, GPIO_PUPD_NONE, gpio_pin[pinNum]);
#endif

pinMode(x, INPUT_PULLUP); should work perfectly fine, the only problem is that we're resetting it to input mode (without pullup or pulldown) during the attachInterrupt process. Will be fixed.

from arduinocore-gd32.

flute2k3 avatar flute2k3 commented on August 21, 2024

I use the board bluepill plus (https://github.com/WeActStudio/BluePill-Plus)

below is the ini file

[env:weact_bluepillplus_gd32f303cc]
platform = gd32
board = weact_bluepillplus_gd32f303cc
framework = arduino

from arduinocore-gd32.

flute2k3 avatar flute2k3 commented on August 21, 2024

oid gpio_interrupt_enable(uint32_t portNum, uint32_t pinNum, vo

in the future in case if I suspect some thing wrong with a function, I can I locate the right place right file as you did, say for example the interrupt? maybe I can do some pre-study/pre-investigation to help with.

from arduinocore-gd32.

flute2k3 avatar flute2k3 commented on August 21, 2024

it works! but this looks not compatible with standard Arduino "style" :-)

from arduinocore-gd32.

maxgerhardt avatar maxgerhardt commented on August 21, 2024

Exactly, that's why we're going to fix this bug in our code here. I think what's either correct is to simply not do the gpio_init() to INPUT_FLOATING (but still turn on the GPIO clock in case that's the first time the pin was used and there's no pinMode() done previously on it), or try to read the old pullup/pulldown mode and set it as the same. The first thing should be easier becasue it's just code removal and the INPUT_FLOATING case is the default GPIO configuration in all microcontrollers I've read.

from arduinocore-gd32.

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.