完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛扫一扫,分享给好友
|
辛勤的工程师及各位大神好:
小弟最近在用omapl138学习6748,想利用板子上的button实现一个外部中断,结合starterware中的一些例程写好了程序,但是中断不运行,一直摸不着头脑,请各位大神指导。 #include "gpio.h" #include "psc.h" #include "interrupt.h" #include "soc_C6748.h" #include "lcdkC6748.h" /****************************************************************************/ /* LOCAL FUNCtiON PROTOTYPES */ /****************************************************************************/ static void ConfigureInt(void); static void ButtonTriggerLED(void); static void GPIOIsr(void); static void Delay(volatile unsigned int delay); /****************************************************************************/ /* GLOBAL VARIABLES */ /****************************************************************************/ volatile unsigned char flag = 0; /****************************************************************************/ /* LOCAL FUNCTION DEFINITIONS */ /****************************************************************************/ void main(void) [ /* The Local PSC number for GPIO is 3. GPIO belongs to PSC1 module.*/ PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_GPIO, PSC_POWERDOMAIN_ALWAYS_ON, PSC_MDCTL_NEXT_ENABLE); /* Pin Multiplexing of pin 12 & 13 of GPIO Bank 6.*/ GPIOBank6Pin12PinMuxSetup(); GPIOBank6Pin13PinMuxSetup(); GPIOBank2Pin4PinMuxSetup(); GPIOBank2Pin5PinMuxSetup(); /* Sets the pin 109 (GP6[12]) & 110 (GP6[13]) as output.*/ GPIODirModeSet(SOC_GPIO_0_REGS, 109, GPIO_DIR_OUTPUT); GPIODirModeSet(SOC_GPIO_0_REGS, 110, GPIO_DIR_OUTPUT); /* Sets the pin 37 (GP2[4]) & 38 (GP2[5]) as input.*/ GPIODirModeSet(SOC_GPIO_0_REGS, 37, GPIO_DIR_INPUT); GPIODirModeSet(SOC_GPIO_0_REGS, 38, GPIO_DIR_INPUT); /* Configure rising edge trigger on pin 37 (GP2[4]) & 38 (GP2[5]) to generate an interrupt.*/ GPIODirModeSet(SOC_GPIO_0_REGS, 37, GPIO_INT_TYPE_RISEDGE); //GPIODirModeSet(SOC_GPIO_0_REGS, 38, GPIO_INT_TYPE_RISEDGE); /*Enable interrupts for Bank 2.*/ GPIOBankIntEnable(SOC_GPIO_0_REGS, 2); ConfigureInt(); while(1) [ if(flag == 1) [ ButtonTriggerLED(); ] ] ]//end of main /* ** brief This function sets up the status of interrupt. ** */ static void ConfigureInt(void) [ IntDSPINTCInit(); //initialize the interrupt controller IntGlobalEnable(); //enable DSP CPU interrupts globally IntRegister(C674X_MASK_INT4, GPIOIsr); //register the ISR in the interrupt vector table IntEventMap(C674X_MASK_INT4, SYS_INT_GPIO_B2INT); //map the system event GPIO_Bank2(BUTTON) to CPU INT4 IntEnable(C674X_MASK_INT4); //enable the CPU masked INT4 IntEventSet(SYS_INT_GPIO_B2INT); //set the EVTFLAG register of GPIO_Bank2 ] /* ** brief Interrupt Service Routine to be executed on GPIO interrupts. ** This disables the bank interrupts, clears the system interrupt ** status and pin interrupt status. This also sets flag as 1. */ static void GPIOIsr(void) [ /* Disable the interrupts for pins of bank 2 in GPIO.*/ GPIOBankIntDisable(SOC_GPIO_0_REGS, 2); /* Clear the system interrupt status in the DSPINTC*/ IntEventClear(SYS_INT_GPIO_B2INT); /* Clears the Interrupt Status of GP2[4] in GPIO.*/ GPIOPinIntClear(SOC_GPIO_0_REGS, 37); flag = 1; ] /* ** brief This function can respond the interrupt. */ static void ButtonTriggerLED(void) [ Delay(0x1FFF); IntGlobalDisable(); //disable DSP CPU interrupts globally /* Clear the system interrupt status in the DSPINTC*/ IntEventClear(SYS_INT_GPIO_B2INT); /* Clears the Interrupt Status of GP2[4] in GPIO.*/ GPIOPinIntClear(SOC_GPIO_0_REGS, 37); if(GPIOPinRead(SOC_GPIO_0_REGS, 37)) [ GPIOPinWrite(SOC_GPIO_0_REGS, 109, GPIO_PIN_HIGH); GPIOPinWrite(SOC_GPIO_0_REGS, 110, GPIO_PIN_LOW); Delay(1000000); GPIOPinWrite(SOC_GPIO_0_REGS, 109, GPIO_PIN_LOW); GPIOPinWrite(SOC_GPIO_0_REGS, 110, GPIO_PIN_HIGH); Delay(1000000); ] else [ GPIOPinWrite(SOC_GPIO_0_REGS, 109, GPIO_PIN_LOW); GPIOPinWrite(SOC_GPIO_0_REGS, 110, GPIO_PIN_LOW); ] flag = 0; /*Enable interrupts for Bank 2.*/ GPIOBankIntEnable(SOC_GPIO_0_REGS, 2); ] /* ** brief This function can be called to generate a delay. */ static void Delay(volatile unsigned int delay) [ while(delay--); ] /*****************************END OF FILE************************************/ |
|
相关推荐
8个回答
|
|
|
|
|
|
|
|
|
请确认有在相关GPIO上给触发信号吗? 建议分两步调试: #1. 手动设置相应的ESR寄存器,看是否能进中断,以确定中断向量与中断函数及CPU的中断配置正确。 #2. 将相应GPIO的方向设为输出,设置相应的SET_DATA寄存器位状态,产生GPIO触发信号。 Note that the direction of the GPIO signal does not have to be an input for the interrupt event generation to work. When a GPIO signal is configured as an output, the software can change the GPIO signal state and, in turn, generate an interrupt. This can be useful for debugging interrupt signal connectivity. http://processors.wiki.ti.com/index.php/Main_Page Think Over Before Asking. http://www.catb.org/~esr/faqs/smart-questions.html#goal |
|
|
|
|
lifei639156 发表于 2018-6-21 06:48 问题已解决,原来是因为GPIO中断引脚被设置成了多功能复用……依然感谢! |
|
|
|
|
|
你好,我想问一下在头文件中有GPIOBank6Pin12PinMuxSetup()函数,但是没有GPIOBank6Pin13PinMuxSetup()这个函数,是要自己写还是我没有把它include进来? |
|
|
|
|
xtl1117 发表于 2018-6-21 07:25 GPIOBank6Pin12PinMuxSetup()这个函数虽然在lcdkOMAPL138.h中定义了,但是编译的时候一直不通过,提示说未定义字符 undefined first referenced symbol in file --------- ---------------- GPIOBank6Pin12PinMuxSetup ./main.obj 这是为什么啊? |
|
|
|
|
何必太在意 发表于 2018-6-21 07:41 这个函数定义在platformlcdkOMAPL138gpio.c里,所以请确认是否包含了相应的platform.lib,正确的目录应该为binaryarmv5cgt_ccsomapl138lcdkOMAPL138platformDebugplatform.lib,不要弄成了evmOMAPL138目录下的platfrom.lib。 http://processors.wiki.ti.com/index.php/Main_Page Think Over Before Asking. http://www.catb.org/~esr/faqs/smart-questions.html#goal |
|
|
|
|
lifei639156 发表于 2018-6-21 08:00 嗯嗯,好的,谢谢!能帮忙看下我intcVectorTable的那个问题吗? |
|
|
|
|
lifei639156 发表于 2018-6-21 08:00 _intcVectorTable与intcVectorTable是在OMAPL138_StarterWare_1_10_04_01system_configc674x中找到的并添加进去的,但是里面只是对其进行了申明,内容没有定义,这是为什么?要自己编写中断向量表吗? |
|
|
|
|
只有小组成员才能发言,加入小组>>
549 浏览 0 评论
1613 浏览 0 评论
2047 浏览 0 评论
为啥BQ7693003DBTR芯片在和BQ769X0盒子通讯时收不到信号?
1513 浏览 0 评论
DSP 28027F 开发板 XDS100v2调试探针诊断日志显示了 Error -150 (SC_ERR_FTDI_FAIL)如何解决
1337 浏览 0 评论
AT32F407在USART2 DMA发送数据时,接包接到了要发送的数据,程序还是处于等待传输完成的标识判断中,为什么?
1757浏览 29评论
2781浏览 23评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
1724浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
1634浏览 14评论
两个TMP117传感器一个可以正常读取温度值,一个读取的值一直是0,为什么?
1645浏览 13评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 08:42 , Processed in 0.791354 second(s), Total 90, Slave 72 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
3758