中断优先级
stm8的中断优先级不是固定不变的,stm8的中断分为硬件优先级与软件优先级;当多个中断发生时,cpu会先响应软件优先级高的中断,若软件优先级相同会先响应硬件优先级高的;
其中软件优先级有四个
/**
* @brief ITC Priority Levels selection
*/
typedef enum {
ITC_PRIORITYLEVEL_0 = (uint8_t)0x02, /*!< Software priority level 0 (cannot be written) */
ITC_PRIORITYLEVEL_1 = (uint8_t)0x01, /*!< Software priority level 1 */
ITC_PRIORITYLEVEL_2 = (uint8_t)0x00, /*!< Software priority level 2 */
ITC_PRIORITYLEVEL_3 = (uint8_t)0x03 /*!< Software priority level 3 */
} ITC_PriorityLevel_TypeDef;
例子:
ITC_SetSoftwarePriority(ITC_IRQ_PORTE,ITC_PRIORITYLEVEL_2 );
外部中断
stm8的所有io引脚都有外部中断能力;
IAR的中断处理声明
在固件库stm8s.h中可以找到这样一段代码
#ifdef _IAR_
#define STRINGVECTOR(x) #x
#define VECTOR_ID(x) STRINGVECTOR( vector =