cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F429 Interrupt question.

Carter Lee
Associate III
Posted on September 07, 2017 at 17:01

Hi 

I've made an interrupt example with referring ST's EXTI_Example.

The code is below, and it seems working, but I'm not sure it works whether correct.

Because, I've expected that the PG14 LED will keep running when I've pushed the 'user' button.

But, PG14 LED blinking is quickly stopped by 

'user' button not postponed .It seems that rest operation canceled by interrupt not wait.

And second question is why does GP13 LED turn off after pushed 'user' button?

I'm just expected that GP13 LED is still turning on after pushed 'user' button. because there is no else statement.

you can see the

https://imgur.com/a/vErXv

/**

******************************************************************************

* @file GPIO/GPIO_IOToggle/main.c

* @author MCD Application Team

* @version V1.8.0

* @date 04-November-2016

* @brief Main program body

******************************************************************************

* @attention

*

* <h2><center>&copy; COPYRIGHT 2016 STMicroelectronics</center></h2>

*

* Licensed under MCD-ST Liberty SW License Agreement V2, (the 'License');

* You may not use this file except in compliance with the License.

* You may obtain a copy of the License at:

*

*

/external-link.jspa?url=http%3A%2F%2Fwww.st.com%2Fsoftware_license_agreement_liberty_v2

*

* Unless required by applicable law or agreed to in writing, software

* distributed under the License is distributed on an 'AS IS' BASIS,

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and

* limitations under the License.

*

******************************************************************************

*/

/* Includes ------------------------------------------------------------------*/

&sharpinclude 'main.h'

/** @addtogroup STM32F4xx_StdPeriph_Examples

* @{

*/

/** @addtogroup GPIO_IOToggle

* @{

*/

/* Private typedef -----------------------------------------------------------*/

GPIO_InitTypeDef GPIO_InitStructure;

EXTI_InitTypeDef EXTI_InitStructure;

NVIC_InitTypeDef NVIC_InitStructure;

/* Private define ------------------------------------------------------------*/

/* Private macro -------------------------------------------------------------*/

/* Private variables ---------------------------------------------------------*/

/* Private function prototypes -----------------------------------------------*/

/* Private functions ---------------------------------------------------------*/

/**

* @brief Main program

* @param None

* @retval None

*/

void delay(void)

{

volatile int i;

for(i=0; i<10000000; i++);

}

void EXTI0_IRQHandler(void){

if(EXTI_GetITStatus(EXTI_Line0)!=RESET) {

GPIOG->ODR =GPIO_Pin_13;

EXTI_ClearITPendingBit(EXTI_Line0);

}

}

int main(void)

{

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG, ENABLE);

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);

RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

// GPIOG->CRL = 0x2800;

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 ;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;

GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;

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(GPIOG, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14;

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(GPIOG, &GPIO_InitStructure);

SYSCFG_EXTILineConfig(0x0,0);

/* Configure EXTI Line0 */

EXTI_InitStructure.EXTI_Line = EXTI_Line0;

EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;

EXTI_InitStructure.EXTI_LineCmd = ENABLE;

EXTI_Init(&EXTI_InitStructure);

NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x00;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x00;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);

/*

GPIOG->BSRRL = GPIO_Pin_13 | GPIO_Pin_14;

delay();

GPIOG->BSRRH = GPIO_Pin_13 | GPIO_Pin_14;

delay();

*/

while (1)

{

GPIOG->ODR =GPIO_Pin_14;

delay();

GPIOG->ODR = 0x00;

delay();

}

}

/*

while (1)

{

GPIOG->BSRRL = GPIO_Pin_13 | GPIO_Pin_14;

delay();

GPIOG->BSRRH = GPIO_Pin_13 | GPIO_Pin_14;

delay();

}

}

*/

/*

while (1)

{

if(GPIOA->IDR & GPIO_Pin_0)

GPIOG->BSRRL = GPIO_Pin_14;

else

GPIOG->BSRRH = 0xFFFF;

}

*/

&sharpifdef USE_FULL_ASSERT

/**

* @brief Reports the name of the source file and the source line number

* where the assert_param error has occurred.

* @param file: pointer to the source file name

* @param line: assert_param error line source number

* @retval None

*/

void assert_failed(uint8_t* file, uint32_t line)

{

/* User can add his own implementation to report the file name and line number,

ex: printf('Wrong parameters value: file %s on line %d\r\n', file, line) */

/* Infinite loop */

while (1)

{

}

}

&sharpendif

/**

* @}

*/

/**

* @}

*/

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

null
2 REPLIES 2
Posted on September 07, 2017 at 17:30

PG13! Does the LED expect a High or Low state to illuminate, check schematic.

Understand these overwrites the entire GPIOG bank output,

GPIOG->ODR =GPIO_Pin_14;

GPIOG->ODR = 0x00;

Use a debugger, step the code, get familiar with what it does

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on September 07, 2017 at 18:35

I'll try to use BSRRL/H not ODR.