cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 interrupt pin strange behavior

Hamid Rajabi
Associate II

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. 

11 REPLIES 11

Observe the pin using oscilloscope or logic analyzer.

JW

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).

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

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

TDK
Guru

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".

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

alister
Lead

k should be volatile.

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

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".

> k should be volatile

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

JW