完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,
这个问题可能非常基本,但我希望得到任何建议,指导教程的链接,甚至是帮助我解决问题的示例代码。 我真的很擅长这个商业。 SPC56控制器系列的可能性很大,但作为初学者,它的复杂性使我感到困惑。我的设置是SPC56xL Discovery Kit和SPC5 Studio与High Tec C编译器的组合。我想做的通常很简单。其中一个LED(例如引脚A0上的LED D5)应由引脚G8上的按钮S2控制。因此,我的想法是使用由按钮S2触发的中断。我使用OSAL-HAL组件设置了一个小项目。 但我真的不知道我应该如何以及在哪里实现我的C代码中的这个功能。到目前为止我所做的就是配置一个中断向量,但我甚至不确定我是否以正确的方式做到了这一点。对我来说主要的问题是: - )配置中断向量的正确方法是什么? - )如何在中断向量和相应的中断源之间建立连接? - )最后,在哪里以及如何定义中断功能以切换我的LED? 我真的很感激任何帮助。 最好的祝福, 帕特里克 以上来自于谷歌翻译 以下为原文 Hello, This question is propably really basic, but I hope to get any advice, a link to a tutorial or even a sample code which helps me to solve my problem. I am really new in this buisness. The possibilities of the SPC56 controller familiy are huge but as a beginner their complexity confuses me. My setting is a SPC56xL Discovery Kit and the SPC5 Studio in combination with the High Tec C compiler. What I want to do is normally very simple. One of the LEDs (e.g. LED D5 on Pin A0) should be controlled by the button S2 on Pin G8. Therefore, my idea was to use an interrupt triggered by the button S2. I set up a small project, using the OSAL-HAL component. But I really have no idea how and where i should implement this functionality in my C code. All what I have done so far is configuring an interrupt vector, but I am even not sure if i did this in the correct way. The main questions for me are: -) What is the correct way to configure an interrupt vector? -) How is the connection between the interrupt vector and the corresponding interrupt source made? -) And finally, where and how to define the interrupt function to toggle my LED? I would be really grateful for any help. Best regards, Patrik |
|
相关推荐
5个回答
|
|
你好Patrik,
1)低级驱动程序中有一些例子(例如:ADC) 如何定义IRQ处理程序 你可以使用OSAL_IRQ_HANDLER OSAL_IRQ_HANDLER(SPC5_ADC0_WD_HANDLER){ uint32_t isr; OSAL_IRQ_PROLOGUE(); isr = ADCD1.adc_tagp-> WTISR.R; ADCD1.adc_tagp-> WTISR.R = isr; adc_lld_serve_interrupt(& ADCD1,isr); OSAL_IRQ_EPILOGUE(); } 在你的情况下, 您可以在SIUL第48章中使用外部中断 和方便的EIRQ [X]第48.4章 你应该使用vector41,vector42,vector 43或vector 44 41 0x0290 16 SIU外部IRQ_0 SIUL 42 0x02A0 16 SIU外部IRQ_1 SIUL 43 0x02B0 16 SIU外部IRQ_2 SIUL 44 0x02C0 16 SIU外部IRQ_3 SIUL 2)对于映射,您应该使用IO设置并在良好模式下设置好的端口/功能 第4章从方便的表''功能汇总'' 3) 在您的IRQ处理程序中,您应该: if(palReadPad(PORT_D,PD_BUTTON1)== 0){ palTogglePad(PORT_D,PD_LED5); } 最好的祝福 二万 以上来自于谷歌翻译 以下为原文 Hello Patrik , 1) there are some examples in low level driver (example : ADC) how to define an IRQ Handler you can use OSAL_IRQ_HANDLER OSAL_IRQ_HANDLER(SPC5_ADC0_WD_HANDLER) { uint32_t isr; OSAL_IRQ_PROLOGUE(); isr = ADCD1.adc_tagp->WTISR.R; ADCD1.adc_tagp->WTISR.R = isr; adc_lld_serve_interrupt(&ADCD1, isr); OSAL_IRQ_EPILOGUE(); } in your case , You can use External INTERRUPT In SIUL chapter 48 and the convenient EIRQ[X] chapter 48.4 you should use vector41 , vector42, vector 43 or vector 44 41 0x0290 16 SIU External IRQ_0 SIUL 42 0x02A0 16 SIU External IRQ_1 SIUL 43 0x02B0 16 SIU External IRQ_2 SIUL 44 0x02C0 16 SIU External IRQ_3 SIUL 2) for mapping you should use IO Settings and set your good port/function in the good mode chap 4 from the convenient table ''function summary'' 3) in your IRQ handler you should have : if (palReadPad(PORT_D, PD_BUTTON1) == 0) { palTogglePad(PORT_D, PD_LED5); } Best regards Erwan |
|
|
|
你好,Erwan,
感谢您的帮助,但对我来说还有一些悬而未决的问题。我现在理解的是如何定义IRQ Handler。我调整了您的代码示例,按下评估板上的按钮S2应激活LED7。 OSAL_IRQ_HANDLER(BUTTON1){ OSAL_IRQ_PROLOGUE(); (palReadPad(PORT_G,PG_BUTTON_S2)== 0){ palClearPad(PORT_G,PA_LED7); // LED连接到+ 3,3V } OSAL_IRQ_EPILOGUE(); } 出于测试目的,我将处理程序放在main.c的main函数中。 但是,我仍然不确定中断向量的定义和配置。按钮S2连接到引脚G [8],意味着EIRQ(21)。我知道vector41到vector44是外部中断的向量,这意味着所有32个可能的外部中断。因为按钮S2连接到G [8],相应的中断向量是vector43(EIRQ [16:23])。 因此,我在main.c#define BUTTON1 vector43中定义了向量43 我使用应用程序配置将引脚G [8]定义为输入,并定义了名称PG_BUTTON_S2。根据产品手册,当使用引脚作为输入时,不需要PADSEL初始化。带LED的引脚定义为推挽输出。 你知道我做错了吗?它没有工作并调试代码显示,从未到达IRQ处理程序。 最好的祝福, 帕特里克 以上来自于谷歌翻译 以下为原文 Hello Erwan, Thanks for your help, but there are still some open questions for me. What I understand now is how I have to define the IRQ Handler. I adapted your code example that pressing the button S2 on the eval board should activate LED7. OSAL_IRQ_HANDLER(BUTTON1){ OSAL_IRQ_PROLOGUE(); (palReadPad(PORT_G,PG_BUTTON_S2)==0){ palClearPad(PORT_G,PA_LED7); //LED is connected to +3,3V } OSAL_IRQ_EPILOGUE(); } For testing purpose, I put the handler in the main function in main.c . But still, I am not sure about definition and configuration of the interrupt vector. The button S2 is connected to the Pin G[8], means EIRQ(21). I understand that vector41 to vector44 are the vectors for external interrupts which means all together 32 possible external interrupts. Because button S2 is connected to G[8] the corresponding interrupt vector is vector43 (EIRQ[16:23]). Therefore, i defined vector 43 in main.c#define BUTTON1 vector43 I used the Application Configuration to define the pin G[8] as an input and defined the name PG_BUTTON_S2. According to the product manual, a PADSEL initilization is not required when using the pin as an input. The pin with the LED is defined as a push-pull output. Do you know what I did wrong? It is not working and debugging the code shows, that the IRQ Handler is never reached. Best regards, Patrik |
|
|
|
自从我上次在这个论坛上写作以来,我多次尝试解决我的中断问题。与此同时,我甚至可以使用PIT模块生成周期性中断并让发现板的LED切换。我不得不说,由于硬件问题,我改为更小的板 - SPC560D发现板。
使用PIT模块工作得很好,但我仍然无法使用外部中断。对程序进行补偿显示,按下按钮时设置了中断标志。但由于原因不明,中断处理程序永远不会执行。我真的不明白这一点,因为我做了一切,就像我使用定时器中断一样。有谁知道这可能是什么原因或我可能忘记配置的? 谢谢, 帕特里克 以上来自于谷歌翻译 以下为原文 Since the last time I write in this forum, I was trying many times to solve my interrupt issue. In the mean time, I was even able to use the PIT module to generate a periodic interrupt and let the LED of the discovery board toggle. I have to say that I changed to a smaller board - the SPC560D discovery board because of a hardware problem. Using the PIT module works really fine, but still I am not able to use the external interrupt. Debbuging the program shows me, that the interrupt flag is set when pressing the button. But because of an unknown reason, the interrupt handler is never executed. I really don´t understand this because i did everything as I did to use the timer interrupt. Has anybody an idea what could be the reason for that or what I maybe forget to configure? Thanks, Patrik |
|
|
|
你好,
最后,我解决了我的问题。我只是忘了为相应的焊盘设置中断使能位。 最好的祝福, 帕特里克 以上来自于谷歌翻译 以下为原文 Hello, Finally, I solved my problem. I just forgot to set the interrupt enable bit for the corresponding pad. Best regards, Patrik |
|
|
|
你好Patrik,
这是一个好消息;-) 无论如何,我们将在应用程序库的新版本中添加一个“测试应用程序”'相对''如何正确使用EIRQ''。 最好的祝福 二万 以上来自于谷歌翻译 以下为原文 Hello Patrik , it is a good news ;-) Anyway , we will add in the new release of Application repository a ''test application'' relative ''how to use correctly the EIRQ''. Best regards Erwan |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2646 浏览 1 评论
3209 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1784 浏览 1 评论
3613 浏览 6 评论
5992 浏览 21 评论
942浏览 4评论
1318浏览 4评论
在Linux上安装Atollic TRUEStudio的步骤有哪些呢?
588浏览 3评论
使用DMA激活某些外设会以导致外设无法工作的方式生成代码是怎么回事
1305浏览 3评论
1365浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-26 23:00 , Processed in 1.435409 second(s), Total 89, Slave 72 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号