完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好。
我最近为stm8s系列下载了ST标准库并使用了这些函数。 在cube mx版本中,当我们调用中断时,会自动执行回调函数,之后,在中断结束时,IRQ HANDLER函数中的标志被清除。 但是在stm8的标准库中,我找不到任何在中断中清除标志的函数。 你能解释一下我该怎么办? 以上来自于谷歌翻译 以下为原文 Hello guys. I've recently downloaded ST standard libraries for stm8s series and working with the functions. In cube mx version when we called an interrupt the callback function automatically was executed and after that, the flag was cleared in IRQ HANDLER function at the end of the interrupt. But in the standard library for stm8 I can't find any functions that have the flag clearing in the interrupts. Would you please explain me how can I manage this? |
|
相关推荐
11个回答
|
|
清除哪个中断标志?
CC寄存器中的一个?这些由iret指令编译器在中断例程结束时清除。 一些特定于设备的标志?这取决于设备。 菲利普 以上来自于谷歌翻译 以下为原文 Clearing which interrupt flag? The one(s) in the CC register? Those are cleared by the iret instruction compilers place at the end of an interrupt routine. Some device-specific flag? That would depend on the device. Philipp |
|
|
|
http://www.st.com/en/embedded-software/stsw-stm8069.html
这是我正在使用的lib。 以上来自于谷歌翻译 以下为原文 http://www.st.com/en/embedded-software/stsw-stm8069.html This is the lib I'm using. |
|
|
|
去抖动的最佳解决方案仍然是硬件(按钮连接到gnd / vcc,当它处于静止状态或完全按下时,在它们之间断开连接,使用电容器将值保持在之前的状态,同时切换。
但有时这是不可用的(当ColecoVision视频游戏系统的逆向游戏编程时,控制器没有这样的硬件去抖动时,我处于同样的情况)。然后一些延迟机制可能是软件去抖动的一部分。 我认为STM8S硬件中的GPIO中断没有明确的标志可以清除。您使用哪种边缘/水平灵敏度设置(EXTI_CR?)? 实现延迟的一种可能性是:按下按钮时,设置带中断的定时器并禁用GPIO中断。在定时器的ISR中,然后重新启用GPIO中断。 菲利普 以上来自于谷歌翻译 以下为原文 Well, the best solution for debouncing is still hardware (have the button connect to gnd/vcc when it is at rest or fully pressed, disconnected in between, use a capacitor to keep the value in the previous state while it is being toggled. But sometimes this is not available (I was in the same situation when programming retrogames for the ColecoVision video game systems where the controllers do not have such hardware-debouncing). Then some delay mechanism might be part of software debouncing. I don't think there is some explicit flag for the GPIO interrupts in STM8S hardware to clear. Which edge/level sensitivity setting do you use (EXTI_CR?)? One possibility to implement the delay would be: When the button is pressed, set a timer with an interrupt and disable the GPIO interrupt. In the ISR for the timer, then reenable the GPIO interrupt. Philipp |
|
|
|
Philipp Krause写道:
我认为STM8S硬件中的GPIO中断没有明确的标志可以清除。您使用哪种边缘/水平灵敏度设置(EXTI_CR?)? 怎么可能没有外部中断的标志?必须有一些标志,MCU发现中断发生。 我搜索了用户手册,但我没有找到任何EXTI标志。 我使用下降沿灵敏度。 Philipp Krause写道: 实现延迟的一种可能性是:按下按钮时,设置带中断的定时器并禁用GPIO中断。在定时器的ISR中,然后重新启用GPIO中断。 如果没有EXT标志,这将是最好的。谢谢很多。 以上来自于谷歌翻译 以下为原文 Philipp Krause wrote: I don't think there is some explicit flag for the GPIO interrupts in STM8S hardware to clear. Which edge/level sensitivity setting do you use (EXTI_CR?)? How can it be possible that there be no flags for the external interrupt?There must be some flags that the MCU finds out that the interrupt occurred. I searched through the user manual but I didn't find any flags for EXTI either. I use falling edge sensitivity. Philipp Krause wrote: One possibility to implement the delay would be: When the button is pressed, set a timer with an interrupt and disable the GPIO interrupt. In the ISR for the timer, then reenable the GPIO interrupt. This would be the best if there is no EXT flag.Thanks alot. |
|
|
|
怎么可能没有外部中断的标志?必须有一些标志,MCU发现中断发生。
我搜索了用户手册,但我没有找到任何EXTI标志。 我使用下降沿灵敏度。 但是该标志不需要用户可写。可能只有一些标志来说明挂起的中断,在中断服务时清除。 菲利普 P.S。:实际上,本手册第63页提到了挂起中断的锁存器。 以上来自于谷歌翻译 以下为原文 How can it be possible that there be no flags for the external interrupt?There must be some flags that the MCU finds out that the interrupt occurred. I searched through the user manual but I didn't find any flags for EXTI either. I use falling edge sensitivity. But that flag need not be writeable by the user. There could just be some flag to account for the pending interrupt, cleared the moment the interrupt is served. Philipp P.S.: Actually there is a mention of a latch for pending interrupts on page 63 of the manual. |
|
|
|
“
在中断结束时,IRQ HANDLER功能清除了该标志。 我发现这是一个不好的做法 - 我在isr的开头清除了标志,所以如果一个事件在我仍然在isr中时到达,它可以被服务 - 执行将立即跳回到isr返回。 如果你最后清除了标志,那么在isr结束之前到达的任何事件都将被忽略。 我想知道为什么st这样做。 以上来自于谷歌翻译 以下为原文 ' the flag was cleared in IRQ HANDLER function at the end of the interrupt.' I find that to be a bad practice - I clear the flag at the beginning of the isr, so that if an event arrives while I'm still in the isr, it can be serviced - the execution will jump right back to the isr upon returning. If you clear the flag in the end, any events arriving before the end of the isr would be ignored. I wonder why st did it this way. |
|
|
|
阿尔曼你好,
我相信菲利普是对的。我检查了STM8S标准外设库中的EXTI文件,但没有找到处理挂起EXTI中断的函数。我不得不说对我来说这也是令人惊讶的......然后我检查了MCU的参考手册(RM0016),这个文件似乎证实了我们的假设。我没有找到一个存储标志的寄存器,表示挂起的EXTI中断。 EXTI模块仅包含EXTI_CR1和EXTI_CR2寄存器,允许设置灵敏度级别(下降沿/上升沿)。最后,我打开了STM8S培训材料的演示文稿,我发现了一个与此主题相关的句子。请看下面的内容。 但请注意,以上所有信息都与STM8S有关,如果我们看一下STM8L,情况就完全不同了。有寄存器,用于保存有关挂起的EXTI中断的信息。这些是EXTI_SR1和EXTI_SR2。因此,STM8L标准外设库提供了一个清除待处理EXTI中断的功能。它被命名为EXTI_ClearITPendingBit()。 问候 Szymon 以上来自于谷歌翻译 以下为原文 Hello Arman, I believe that Philipp is right. I checked EXTI files from STM8S Standard Peripheral Library and I didn't find a function to handle pending EXTI interrupt. I have to say that for me it was surprising as well... Then I checked MCU's reference manual (RM0016) and this document seems to confirm our assumption. I didn't find a register, which stores flags, that indicate pending EXTI interrupt. EXTI module contains only EXTI_CR1 and EXTI_CR2 registers, which allow to set sensitivity level (falling/rising edge). Finally I opened presentation from STM8S training material and I found a sentence related to this subject. Please see it below. However please note that all above information is related to STM8S and if we take a look on STM8L, the situation is completely different. There are registers, which keep the information about pending EXTI interrupt. These are EXTI_SR1 and EXTI_SR2. Therefore STM8L Standard Peripheral Library provides a function, which clears pending EXTI interrupt. It is named EXTI_ClearITPendingBit(). Regards Szymon |
|
|
|
你好dhenry,
ST库中没有这样的问题。如果我们引用EXTI处理程序,我们可以看到这样的代码: 我们可以在HAL_GPIO_EXTI_IRQHandler()函数之前输入用户代码,该函数清除标志或之后。 如果我们指的是身体 HAL_GPIO_EXTI_IRQHandler()函数,我们再次看到该标志在HAL_GPIO_EXTI_Callback()之前被清除,可以由用户重新实现,例如在main.c中。 问候 Szymon 以上来自于谷歌翻译 以下为原文 Hello dhenry, There is no such problem in ST library. If we refer to the EXTI handler, we can see such code:
We can enter user code either before HAL_GPIO_EXTI_IRQHandler() function, which clears the flag or after it. And if we refer to body of HAL_GPIO_EXTI_IRQHandler() function, we see again that flag is cleared before HAL_GPIO_EXTI_Callback(), which can be reimplemented by user for example in main.c.
Regards Szymon |
|
|
|
谢谢。听起来像SPL的概念清除isr末尾的标志是完全错误的。
以上来自于谷歌翻译 以下为原文 thanks. sounds like the notion of the SPL clearing the flag at the end of an isr is simply wrong. |
|
|
|
如果我们例如接收数据,如果首先没有清除标志,那么这将是重要的,因此数据将被丢失。但在我的情况下,只有一个按钮与用户通信不是那么快,数据通信是。
菲利普说我可以使用一个电容器来减少按钮的弹跳。你有没有任何参考资料解释如何设置这个上限或有关此问题的任何数据? 如果我们指的是身体 HAL_GPIO_EXTI_IRQHandler()函数,我们再次看到该标志在HAL_GPIO_EXTI_Callback()之前被清除,该标志可以由用户重新实现,例如在main.c中。 哟这件事是正确的,但我认为你可以削减回调功能,并在清除旗帜后放置它。 但问题是,当你首先清除标志时,最后一次中断会发生什么?在这种情况下,最后的中断会被遗漏? 以上来自于谷歌翻译 以下为原文 This would be important if we are for example receiving data that if the flag is not cleared at first so the data will be missed.But in my case just there is a button to communicate with the user that is not so speedy that data communication is. Philipp said that I can use a capacitor to reduce bouncing of the push buttons.Do you have any references that explained how to place this cap or any data about this matter? And if we refer to body of HAL_GPIO_EXTI_IRQHandler() function, we see again that flag is cleared before HAL_GPIO_EXTI_Callback(), which can be reimplemented by user for example in main.c. Yo are right about this matter, but I think you can cut that call back function and just place it after clearing the flag. But the matter is that when you clear the flag at first, so what happens to the last interrupt occurred?In this matter, the last interrupt will be missed? |
|
|
|
我忘了提到的一点是,在stm8s中,Szymon Panecki提到没有挂起中断的寄存器。但我认为在这种情况下,标志或它是什么(我们无法访问)会自动清除因为中断已经发生了。原因是如果在中断程序结束时它被清除,如果我放了一个延迟,则在延迟通过之前不会发生下一个中断,但是即使在几秒钟之后,也会产生中断。按下按钮的时间。
我对吗? 以上来自于谷歌翻译 以下为原文 Something that I forgot to mention is that in stm8s as Szymon Panecki mentioned there are no registers for pending interrupts.But I think that in this case the flag or whatever it is(that we don't have access to) is automatically cleared as soon as the interrupt has occurred.The reason is that if it was cleared at the end of the interrupt routine if I put a delay the next interrupt wouldn't occur till the delay is passed, but after even some seconds delay the interrupt is generated every time pushing the push button. Am I right? |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2270 浏览 1 评论
3044 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1619 浏览 1 评论
3433 浏览 6 评论
5777 浏览 21 评论
781浏览 4评论
1149浏览 4评论
在Linux上安装Atollic TRUEStudio的步骤有哪些呢?
419浏览 3评论
使用DMA激活某些外设会以导致外设无法工作的方式生成代码是怎么回事
1133浏览 3评论
1181浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-8-19 15:47 , Processed in 1.197783 second(s), Total 66, Slave 60 queries .
Powered by 电子发烧友网
© 2015 www.ws-dc.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号