Author Topic: stm32f103-Can't trigger IRQ9_5 interrupt?  (Read 959 times)

0 Members and 1 Guest are viewing this topic.

Offline kgavionicsTopic starter

  • Regular Contributor
  • *
  • Posts: 225
  • Country: ca
stm32f103-Can't trigger IRQ9_5 interrupt?
« on: April 20, 2022, 05:15:00 pm »
Hello, I'm a new to the STM32 programming. I'm coming from the AVR ! So don't be too hard on me  ;D ;D
I'm trying to trigger an interrupt using the below  code, but I can't trigger the interrupt. When I press on the switch, nothing happens. I don't know what I'm doing wrong. Can someone help me please?
Code: [Select]
#include <stm32f10x.h>
// PA6 connected to an external pull-up resitor and a momentary switch

void EXTI9_5_IRQHandler()
{
EXTI->PR |=(1<<6); // Clear pending interrupt
GPIOA->ODR ^=(1<<7);// Toggle a led connected to PA7
}


int main()
{
RCC->APB2ENR |= (1<<0) | (1<<2); //enable GPIOA and AFIO cloks

  GPIOA->CRL =0x34444444; //P7 output, the rest are inputs
AFIO->EXTICR[1]=0;// EXTI6 (BITS 8-9-10-11 are 0000) 
EXTI->FTSR |=(1<<6);// Falling edge
EXTI->EMR |=(1<<6); // unmasked intp6
NVIC_EnableIRQ(EXTI9_5_IRQn);

while(1);

}
 

Offline hans

  • Super Contributor
  • ***
  • Posts: 1732
  • Country: 00
Re: stm32f103-Can't trigger IRQ9_5 interrupt?
« Reply #1 on: April 20, 2022, 05:23:38 pm »
You could try to use IMR instead of EMR of the EXTI registers.

Event and interrupts are separate in STM32 (and more ARM CPUs, but not all): interrupts trigger a software interrupt vector, while an event is typically used between peripherals as triggers (e.g. for DMA, timer updates, or other peripheral 'events')
« Last Edit: April 20, 2022, 05:25:32 pm by hans »
 
The following users thanked this post: kgavionics

Offline kgavionicsTopic starter

  • Regular Contributor
  • *
  • Posts: 225
  • Country: ca
Re: stm32f103-Can't trigger IRQ9_5 interrupt?
« Reply #2 on: April 20, 2022, 05:35:18 pm »
Thank you very much Hans, by changing EMR to IMR,  my code worked right away!
Thanks again, you really made my day!
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6582
  • Country: es
Re: stm32f103-Can't trigger IRQ9_5 interrupt?
« Reply #3 on: April 22, 2022, 04:47:36 am »
Was going to say that.
Doesn't ARMs need to configure the nvic, setting the jump locations?
He's doing it bare-metal so he will have to take care of every single bit.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline kgavionicsTopic starter

  • Regular Contributor
  • *
  • Posts: 225
  • Country: ca
Re: stm32f103-Can't trigger IRQ9_5 interrupt?
« Reply #4 on: April 23, 2022, 12:57:33 am »
My code above,is taking care of everything.the only mistake I made is that I used EMR instead of IMR register.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf