STM32F103C8 attachinterrupt

Any other STM32 based boards
Post Reply
vib
Posts: 12
Joined: Wed May 03, 2017 7:35 pm

STM32F103C8 attachinterrupt

Post by vib » Wed May 03, 2017 7:44 pm

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

vib
Posts: 12
Joined: Wed May 03, 2017 7:35 pm

Re: STM32F103C8 attachinterrupt

Post by vib » 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 ;)

User avatar
zoomx
Posts: 541
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: STM32F103C8 attachinterrupt

Post by zoomx » Fri May 05, 2017 7:55 am

Putting a Serial.Print into the interrupt routine is not a good idea but it seems that it works.....

vib
Posts: 12
Joined: Wed May 03, 2017 7:35 pm

Re: STM32F103C8 attachinterrupt

Post by vib » Wed May 10, 2017 11:48 am

Thank you for your input, this is only for debug ;9
This is removed in the final sketch

salwan
Posts: 4
Joined: Tue Jun 20, 2017 1:27 pm

Re: STM32F103C8 attachinterrupt

Post by salwan » Tue Jun 20, 2017 8:45 pm

hi vib , please can you show me your hx711 library and main code ?

User avatar
RogerClark
Posts: 7460
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: STM32F103C8 attachinterrupt

Post by RogerClark » Tue Jun 20, 2017 10:29 pm

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.

Post Reply