Page 1 of 1

STM32F103C8 attachinterrupt

Posted: Wed May 03, 2017 7:44 pm
by vib
Hi everyone,
This is my first post and I'm really new to STM32 chip. I spent few hours and developed few projects on arduino but I want to switch on STM32.
I have to admit this is not an easy move for me.

here is my problem:
I made a digital scale for a specific purpose and used HX711 library.
Sometime, I need to set tare the scale (sorry if my english is not really good) so i use scale.tare(); function.
To enable this function I put a push button. I tried to kept it simple: button is wired to PB0 from on side and ground the other side.
I tried something with debounce but it was not working for me and as a final solution, I tried an attachinterrupt because I really like the way it works.
Unfortunatelly, when I lunch my sketch with this attachinterrupt code, this is like my push button is always pressed and I don't know why.
Any idea?

Code (only the attachinterrupt part):

Code: Select all

attachInterrupt(PB0, scaletare, RISING); // I tried Rising, change, same result
void scaletare()
{
    scale.tare();
    Serial.println("tare !");
}
and push buton wiring/ + on PB0 and - to gnd

Thank you for your help

Re: STM32F103C8 attachinterrupt

Posted: Wed May 03, 2017 8:26 pm
by vib
Here is the answer: I had to much noise with the wiring like this.
I just add the pinmode as inputpullup and everything is fine ;)

Re: STM32F103C8 attachinterrupt

Posted: Fri May 05, 2017 7:55 am
by zoomx
Putting a Serial.Print into the interrupt routine is not a good idea but it seems that it works.....

Re: STM32F103C8 attachinterrupt

Posted: Wed May 10, 2017 11:48 am
by vib
Thank you for your input, this is only for debug ;9
This is removed in the final sketch

Re: STM32F103C8 attachinterrupt

Posted: Tue Jun 20, 2017 8:45 pm
by salwan
hi vib , please can you show me your hx711 library and main code ?

Re: STM32F103C8 attachinterrupt

Posted: Tue Jun 20, 2017 10:29 pm
by RogerClark
vib wrote:
Wed May 03, 2017 8:26 pm
Here is the answer: I had to much noise with the wiring like this.
I just add the pinmode as inputpullup and everything is fine ;)

Be aware the internal pullup is very weak. I think the spec says it can be anywhere between 30k and 50k

I tried using the internal pullup with a rotary encoder, but found it was too weak, and I seemed to occasionally get glitches.
So I had to use a much lower value external resistor.