/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / Redundant interrupt occurence

Username:     
Password:     
             

Forum

# 1   2008-11-23 06:31:01 Redundant interrupt occurence

delphin
New member
Registered: 2008-11-23
Posts: 2

Redundant interrupt occurence

Hello,

I write firmware for STM32F10x microcontroller.
I use IAR evaluation board and Workbench for developing and debugging.
Problem Description:
--
I tried to use one of the evaluation board buttons as a source for external interrupt.
I used EXTI example as a reference for writing the code.
Press on the button really causes corresponding interrupt generation.
The only problem is that I get an interrupt right after I enable it in NVIC module (I don't press on the button at this time)

My code:

int main()
{
u32 i,j;
GPIO_TypeDef* GPIOx;
u8 bitVal;



#ifdef DEBUG
debug();
#endif



/* System clocks configuration */
RCC_Configuration();

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

NVIC_Configuration();

GPIO_Configuration();

EXTI_Configuration();


while(1)
{

}

}

where

void GPIO_Configuration(void)
{
GPIO_InitStruct->GPIO_Pin = GPIO_Pin_4;
GPIO_InitStruct->GPIO_Speed = 0;
GPIO_InitStruct->GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOC, &GPIO_InitStruct); // Port C bit 4
}


void NVIC_Configuration(void)
{NVIC_InitTypeDef NVIC_InitStructure;

#ifdef VECT_TAB_RAM
/* Set the Vector Table base location at 0x20000000 */
NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
#else /* VECT_TAB_FLASH */
/* Set the Vector Table base location at 0x08000000 */
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
#endif

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

/* Enable the EXTI4_IRQChannel */
NVIC_InitStructure.NVIC_IRQChannel = EXTI4_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);

NVIC_ClearIRQChannelPendingBit(EXTI4_IRQChannel);
}

void EXTI_Configuration(void)
{
EXTI_InitTypeDef EXTI_InitStruct;

GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource4); // Port C Bit 4
EXTI_InitStruct.EXTI_Line = EXTI_Line4;
EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStruct.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStruct);

EXTI_ClearITPendingBit(EXTI_Line4);
}


How can I prevent the redundant interrupt generation?
Please help.

Last edited by delphin (2008-11-23 08:55:20)

Offline

 

Board footer