完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
/**************************************************************************//**
* @file main.c * @version V3.00 * $Revision: 3 $ * $Date: 14/01/28 11:44a $ * @brief NUC029 Series GPIO Driver Sample Code * * @note * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. ******************************************************************************/ #include #include "NUC029xAN.h" #define PLL_CLOCK 50000000 /** * @brief External INT0 IRQ * * @param None * * @return None * * @Details The External INT0(P3.2) default IRQ, declared in startup_NUC029xAN.s. */ void EINT0_IRQHandler(void) { /* For P3.2, clear the INT flag */ GPIO_CLR_INT_FLAG(P3, BIT2); printf("P3.2 EINT0 occurred.\n"); } /** * @brief External INT1 IRQ * * @param None * * @return None * * @details The External INT1(P3.3) default IRQ, declared in startup_NUC029xAN.s. */ void EINT1_IRQHandler(void) { /* For P3.3, clear the INT flag */ GPIO_CLR_INT_FLAG(P3, BIT3); printf("P3.3 EINT1 occurred.\n"); } void SYS_Init(void) { /*---------------------------------------------------------------------------------------------------------*/ /* Init System Clock */ /*---------------------------------------------------------------------------------------------------------*/ /* Enable Internal RC 22.1184MHz clock */ CLK_EnableXtalRC(CLK_PWRCON_OSC22M_EN_Msk); /* Waiting for Internal RC clock ready */ CLK_WaitClockReady(CLK_CLKSTATUS_OSC22M_STB_Msk); /* Switch HCLK clock source to Internal RC and HCLK source divide 1 */ CLK_SetHCLK(CLK_CLKSEL0_HCLK_S_HIRC, CLK_CLKDIV_HCLK(1)); /* Enable external XTAL 12MHz clock */ CLK_EnableXtalRC(CLK_PWRCON_XTL12M_EN_Msk); /* Waiting for external XTAL clock ready */ CLK_WaitClockReady(CLK_CLKSTATUS_XTL12M_STB_Msk); /* Set core clock as PLL_CLOCK from PLL */ CLK_SetCoreClock(PLL_CLOCK); /* Enable UART module clock */ CLK_EnableModuleClock(UART0_MODULE); /* Select UART module clock source */ CLK_SetModuleClock(UART0_MODULE, CLK_CLKSEL1_UART_S_PLL, CLK_CLKDIV_UART(1)); /*---------------------------------------------------------------------------------------------------------*/ /* Init I/O Multi-function */ /*---------------------------------------------------------------------------------------------------------*/ /* Set P3 multi-function pins for UART0 RXD, TXD, EINT0 and EINT1 */ SYS->P3_MFP &= ~(SYS_MFP_P30_Msk | SYS_MFP_P31_Msk | SYS_MFP_P32_Msk | SYS_MFP_P33_Msk); SYS->P3_MFP |= (SYS_MFP_P30_RXD0 | SYS_MFP_P31_TXD0 | SYS_MFP_P32_INT0 | SYS_MFP_P33_INT1); } void UART0_Init(void) { /*---------------------------------------------------------------------------------------------------------*/ /* Init UART */ /*---------------------------------------------------------------------------------------------------------*/ /* Reset UART */ SYS_ResetModule(UART0_RST); /* Configure UART0 and set UART0 Baudrate */ UART_Open(UART0, 115200); } /*---------------------------------------------------------------------------------------------------------*/ /* MAIN function */ /*---------------------------------------------------------------------------------------------------------*/ int main(void) { /* Unlock protected registers */ SYS_UnlockReg(); /* Init System, peripheral clock and multi-function I/O */ SYS_Init(); /* Lock protected registers */ SYS_LockReg(); /* Init UART0 for printf */ UART0_Init(); printf("\n\nCPU @ %d Hz\n", SystemCoreClock); printf("+------------------------------------------------------------+\n"); printf("| GPIO EINT0/EINT1 Interrupt and De-bounce Sample Code |\n"); printf("+------------------------------------------------------------+\n\n"); /*-----------------------------------------------------------------------------------------------------*/ /* GPIO External Interrupt Function Test */ /*-----------------------------------------------------------------------------------------------------*/ printf("EINT0(P3.2) and EINT1(P3.3) are used to test interrupt \n"); /* Configure P3.2 as EINT0 pin and enable interrupt by falling edge trigger */ GPIO_SetMode(P3, BIT2, GPIO_PMD_INPUT); GPIO_EnableEINT0(P3, 2, GPIO_INT_FALLING); NVIC_EnableIRQ(EINT0_IRQn); /* Configure P3.3 as EINT1 pin and enable interrupt by rising and falling edge trigger */ GPIO_SetMode(P3, BIT3, GPIO_PMD_INPUT); GPIO_EnableEINT1(P3, 3, GPIO_INT_BOTH_EDGE); NVIC_EnableIRQ(EINT1_IRQn); /* Enable interrupt de-bounce function and select de-bounce sampling cycle time is 1024 * 10 KHz clock */ GPIO_SET_DEBOUNCE_TIME(GPIO_DBCLKSRC_LIRC, GPIO_DBCLKSEL_1024); GPIO_ENABLE_DEBOUNCE(P3, BIT2 | BIT3); /* Waiting for interrupts */ while(1); } /*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ 中断去抖动可以达到什么目的呢,或者说有什么效果呢? |
|
相关推荐
1个回答
|
|
中断去抖动可以防止由于外部信号(如按键)的抖动造成误触发中断。去抖动的原理是在一定的时间间隔内,只允许第一个触发中断的信号通过,其他信号被过滤掉,从而保证中断的正确性。NUC029的IO中断开启去抖动功能可以提高系统的稳定性和可靠性。
|
|
|
|
只有小组成员才能发言,加入小组>>
880 浏览 1 评论
2277 浏览 5 评论
2588 浏览 9 评论
移植了freeRTOS到STMf103之后显示没有定义的原因?
2396 浏览 6 评论
2295 浏览 7 评论
使用eim外接fpga可是端口一点反应都没有有没有大哥指点一下啊
444浏览 9评论
453浏览 7评论
请教大神怎样去解决iMX6Q在linux3.0.35内核上做AP失败的问题呢
559浏览 6评论
434浏览 5评论
468浏览 5评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-8-16 13:56 , Processed in 1.008950 second(s), Total 79, Slave 60 queries .
Powered by 电子发烧友网
© 2015 www.ws-dc.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号