cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 discovery External interrupts not working

sankhar
Associate
Posted on February 06, 2014 at 07:49

I wrote a code to generate rising edge interrupts for a 4MHz clock input to the board. The 4MHz input is generated by MCO while the core is pushed to 168MHz. 

I found that certain interrupts are not being tacked at all and when they are tackled, there are delays often (but not always) for the Microcontroller to enter ISR.

I am simply toggling external pin in the ISR

MAIN.C__________________________________________________________

int main(void)

{

  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOC, ENABLE);

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;

  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

  GPIO_Init(GPIOC, &GPIO_InitStructure);

      GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_8;

      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

      GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

      GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

      GPIO_Init(GPIOA, &GPIO_InitStructure);

      GPIO_PinAFConfig(GPIOA, GPIO_Pin_8, GPIO_AF_MCO);

      RCC_MCO1Config(RCC_MCO1Source_HSE,RCC_MCO1Div_2); 

      EXTILine1_Config( );

  while (1);

}

void MCO_CLK_CONFIG(void){

RCC_HSEConfig(RCC_HSE_ON);

while(!RCC_WaitForHSEStartUp())

{

}

}

void EXTILine1_Config(void)

{

  /* Enable SYSCFG clock */

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;

  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;

  GPIO_Init(GPIOA, &GPIO_InitStructure);

  SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource1);

  EXTI_InitStructure.EXTI_Line = EXTI_Line1;

  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;

  EXTI_InitStructure.EXTI_LineCmd = ENABLE;

  EXTI_Init(&EXTI_InitStructure);

  NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn;

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x00;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x00;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure);

}

ISR________________________________________________________________________________________________ISR

void EXTI1_IRQHandler(void)

{

  if(EXTI_GetITStatus(EXTI_Line1) != RESET)

  {

  GPIOC->BSRRL = GPIO_Pin_9;

  GPIOC->BSRRH = GPIO_Pin_9;

  EXTI_ClearITPendingBit(EXTI_Line1);

}

}

Following is the image on Logic analyzer we captured.

0690X00000605XEQAY.png

Can someone enlighten me regarding what the issue can be?

Thank you
2 REPLIES 2
Posted on February 06, 2014 at 08:48

If the ''ISR RESPONSE'' trace is produced by two consecutive writes to GPIO

  GPIOC->BSRRL = GPIO_Pin_9;

  GPIOC->BSRRH = GPIO_Pin_9;

then you are probably not running the processor at 168MHz.

JW

Posted on February 06, 2014 at 16:00

4 MHz is a bit excessive! Try 40 KHz or 400 KHz first.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..