Skip to main content
Hamid Rajabi
Associate
September 17, 2021
Question

STM32 interrupt pin strange behavior

  • September 17, 2021
  • 5 replies
  • 2537 views

I am using stm32cubeide to program a stm32f030f4p6 MC. I have assigned one pin as an external interrupt and it is connected to the data output of an RF433 receiver. 

Here is a summary of my code:

int k;
 
int main(void)
 
{
 
 while (1)
 
 {
 
 k=0;
 
 }
 
}
 
 
 
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
 
{
 
 k=1;
 
 }

and, the value of 'k' over time is:

0693W00000DnW4UQAV.png 

the value of 'k' over time("button" is the button of the rf433 transmitter)

as it can be seen from the picture, interrupt is triggered even when no signal is received. 

PS. I have tried external pull down and pull pull up resistors 10k and 4.7 k did not have an effect and with 2.2k no signal from rf433 receiver would be detected. 

This topic has been closed for replies.

5 replies

waclawek.jan
Super User
September 17, 2021

Observe the pin using oscilloscope or logic analyzer.

JW

Hamid Rajabi
Associate
September 17, 2021

Thanks for the reply.

I don't have access to oscilloscope or logic analyzer. However, I was able to observe the value of 'k' (which becomes 1 by interrupt ) by the stm32cubeMonitor (the attached picture).

waclawek.jan
Super User
September 17, 2021

And how do you know the observed behaviour is incorrect, ie. how do you know that there are no oscillations on the input pin?

JW

Hamid Rajabi
Associate
September 17, 2021

I have the assumption that the pin should only oscillate while receiving 433mhz signal.

TDK
September 17, 2021

Sure seems like the pin is toggling even when you don't expect it, doesn't it? What would be a different explanation?

Disconnect the pin and tie it to ground. I'll bet the variable doesn't change anymore.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Hamid Rajabi
Associate
September 17, 2021

In that case the pin won't toggle even when I expect it (receiving 433mhz signal).

TDK
September 17, 2021
Agreed. However, it would show you the issue is not with the code but rather with your expectations of what the hardware is doing.
"If you feel a post has answered your question, please click ""Accept as Solution""."
alister
Senior III
September 17, 2021

k should be volatile.

The suggestion to tie the pin to ground wasn't hypothetical. It's intended to find something unknown.

waclawek.jan
Super User
September 17, 2021

> k should be volatile

I agree, but I also find it unlikely it would change, would it be optimized out.

JW

alister
Senior III
September 18, 2021

And I agree, but the OP posted only summary code and something may be being partially optimised out. For the summary code, it should be volatile. I would want to know if it makes any difference.

alister
Senior III
September 18, 2021

>STM32 interrupt pin strange behavior

Is the receiver output ASK modulated or what?

Using a CRO with 2 or more channels, post a capture of both the button of the transmitter and the receiver output.

What antennas? Try 17.31cm straight, single-core wire and align them parallel. It's the parallel length that matters.

Can you detect interference? E.g. have you a spectrum analyzer you could connect an antenna?

Receiver could be saturated. Try increasing the distance.

Describe how k is acquired.