STM8常用中断指令
- 开总中断
- _asm(“rim”);
- 禁止中断
- _asm(“sim”);
- 进入停机模式
- _asm(“halt”);
- 中断返回
- _asm(“iret”);
- 等待中断
- _asm(“wfi”);
- 软件中断
- _asm(“trap”);
STM8S常用中断映射
如使用中断函数时,可以通过在上图中查找相对应的中断向量号,而中断函数的名字可以自定义
/* BASIC INTERRUPT VECTOR TABLE FOR STM8 devices
* Copyright (c) 2007 STMicroelectronics
*/
typedef void @far (*interrupt_handler_t)(void);
struct interrupt_vector {
unsigned char interrupt_instruction;
interrupt_handler_t interrupt_handler;
};
@far @interrupt void NonHandledInterrupt (void)
{
/* in order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction
*/
return;
}
extern void _stext(); /* startup routine */
extern @far @interrupt void EXTI2_Hand_Fun(void);
extern @far @interrupt void TIM1_UPD_OVF_TRG_BRK_IRQHandler(void);
struct interrupt_vector const _vectab[] = {
{
0x82, (interrupt_handler_t)_stext}, /* reset */
{
0x82, NonHandledInterrupt}, /* trap */
{
0x82, NonHandledInterrupt}, /* irq0 */
{
0x82, NonHandledInterrupt}, /* irq1 */
{
0x82, NonHandledInterrupt}, /* irq2 */
{
0x82, NonHandledInte